I want my player to Move only in Vertical Direction in Unity, but the player is moving Crosswards (X /) why? How to solve this ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

I want my player to Move only in Vertical Direction in Unity, but the player is moving Crosswards (X /) why? How to solve this ?

My Input and Expected output :- I want my player to move in the vertical direction only, when the person (Anyone) clicks the UI Button of upward direction the object must go upwards. Similarly, When the person click the UI Button of downward direction the object must Come Down Issue :- The Player is not Following the same it is moving Crosswards (X, /). There must be a Problem in axis pls Help Link of Code is above check it. Link:- https://code.sololearn.com/cl32x3I9UeMD/?ref=app

10th Jul 2021, 12:21 PM
Yash Saple
5 Answers
+ 2
YUGRAJ Yes, in that line there was an issue After an Quite Search I Solved my Issue (Other Full Code is right) It should be like this :- private void FixedUpdate() { rb.velocity = new Vector2(rb.velocity.x, Vertical Move * Time.deltaTime); } Thank You
10th Jul 2021, 2:09 PM
Yash Saple
5th Sep 2021, 6:49 AM
YUGRAJ
+ 2
In this line rb.velocity = new Vector2(VerticalMove, rb.velocity.x); You should pass verticalmove as second argument as it denotes y axis first argument is for x
10th Jul 2021, 1:58 PM
YUGRAJ
+ 2
Yash Saple there is a YouTube channel named brackeys best channel for learning unity try it maybe you learn new things😁
14th Jul 2021, 9:31 AM
YUGRAJ
0
Marshmello =) I am as well a Beginner I completed my First game Yesterday. But that game was not fully made by me I just made it to get to know how the unity Engine works. Still I am having a Problem in aspect ratio of the game ') but I will fix it very soon..... I don't know much but I practice in different way. For example :- ( WRITE YOUR NAME IN INPUT ) https://code.sololearn.com/c8GS3LZ2F2Oe/?ref=app Thank you :={
14th Jul 2021, 7:17 AM
Yash Saple