Right now i have a movement like this
But i want to move by changing 5 line. .-. Help please
You will not solve anything by “changing line 5”. That’s not a thing.
Screenshots of code is also not a thing. If you post a code snippet, ALWAYS USE CODE TAGS:
How to use code tags: Using code tags properly
Generally speaking, if you want to copy an existing game, type “unity” and “game I want to copy” into google and follow any one of the thousands of different tutorial videos that appear.
Here, I did it for you:
I m not trying to copy a game, thing i need its a advice how to make a character movement like in subway surf or temple run. When you move by changing the lines by press A D key(swipe right or left). I hope you understand what i’m wrote.
I know how to use google, but there is a one thing. First i watch a indian dude who made a movement controller based on a IF ELSE statements, next i watch dude who use just “rb.addforce”
I don’t think you understand. If you follow a tutorial like the ones listed above, you’ll have your controller and a better understanding on how it’s made. Then you can edit it how you please. Even if you’re not making a clone, saying the movement is “like subway surfers or temple run” means you’ll want to follow tutorials for one of those games.
I think that you can’t move a Rigid Body just changing the position.
If you need to do so you must do some other things first.
If I remember well you must disable is kinematic, move the RB, and then re-enable is kinematic.
And also look in the new position: is it colliding?
What Kurt was asking is to put the code instead of a screenshot. So that we can copy and test faster the code. Or add code to it in a simple way.
I personally didn’t t understand “changing 5 line”, did you mean “changing this 5 lines”?
Mate, if im not watched them early i dont come to unity forum. The mechanic they use is not working well in my case. Look, i have 5 empty objects in the same Y axis and want player.object teleport to this 5 objects position (by pressing A and D key) i already try to hardcode it like in tutorial(dude use if else to check player pos and change it to the position of 5 empty objects) and that code isn’t working.
And how would you describe the mechanic you ARE looking for?
Now… where is the most popular game where you have SEEN that mechanic?
Now type that game’s name into youtube along with “unity” and if nothing comes up, take a screenshot and show us.
5 lines means i have 5 obstacle spawn points and want player position be parallel this points.
I tried to assign the position of these points to the player object, but of course it did not work.
By the way, well come to this forum!
Are you trying to move a rigid body?
You should make a int for position, then use get button down to move the int up or down by 1 and have the character move to that space, all while temporarily disabling movement while the character moves to that location.
And games like subway surfers don’t use physics. You don’t want addforce.
you want the player snapping to lanes.
so lets say there’s 5 lanes.
number the lanes 1, 2, 3, 4, and 5.
Start the player in lane 3.
make an int that represents the lane you’re in. So make it 3 at start.
then make a bool that represents you can move. Start it as true.
when you press left or right and can move have that int move down one (left) or up one (right) then turn the bool false, have the character move to that point, and turn back to true when it’s there.
if the int is less than 1 or greater than 5 set it to 1 or 5 and return it before the rest of the code executes.
Thank you man. It works. And work amazing
i solve that by moving player using vector3 (i spend a ****in lot of time, and now can use it finally)
last what i need to do is use a mathf.clamp because player can move out of the ground.
Actually your advice was the best, thank you. Best way to learn something is a fing info about info you need.-.