How can I get a player to move in one direction and around it in the same time unity 2D
I just startet on a endless runner game, what I want to do is that the player should run upward, but right now I cant figure out how the player can run upwards in the same direction, right now he runs out of the field, which he shouldnt. The idea is that the player stays in the same position, so the user just needs to jump and not steer the player. Hope its clear where I want to go :-)
Can you try to clarify what do you want please? I am a bit confuse about it
Sure, sorry :-) So right now the player (cube) are moved by $$anonymous$$yRigidBody.velocity = new Vector2(speed, $$anonymous$$yRigidBody.velocity.y);
But when the player have been jumping around the scene 2-3 time it goes out of the field and then it cant hit the planes, and then gets away from the game. So I need to have the player to stay in the same position so it dont get out of the field.
Answer by Suduckgames · Feb 28, 2017 at 12:14 PM
So If I understand correctly what you want is your character to jump in the same way every time,
The probelm is that you are incremting the velocity in Y axis every time you use that code
I don't know if this will work but try it
MyRigidBody.velocity = Vector3.up*speed;
However , If you are using gravity on rigidbody I recommend you to use MyRigidBody.AddForce() instead of setting the velocity of the rigid body, since you can use 1 time AddForce and it is done
Your answer
Follow this Question
Related Questions
How to Make Game Object (Enemy) Move (Right to Left) in 2D Endless Runner Game? 0 Answers
increasing speed of a player based on score? 0 Answers
Error CS0246: The type or namespace name 'ChallengeController' could not be found. 0 Answers
Player cannot double jump 1 Answer
Pause scene when character hit object, then resume it from another scene 0 Answers