- Home /
rigidbody velocity on x axis and addforce on y axis ??
how can i make my object can use rigidbody velocity on x axis and addforce on y axis, i want to move my character with velocity and make jump and gravity with addforce, i try :
vector3 forced = new vector3 (0, transform.position.y, 0);
myRb.AddForce(forced);
vector3 mov = new vector3 (transform.position.x, 0, 0);
myRb.velocity = (move * speed);
but it's not move like i want, how can i make velocity just on x axis, and addforce on y axis cause i want to make gravity and jump.
Comment
Best Answer
Answer by unity_21erushbrook · Jul 22, 2019 at 03:39 AM
myRb.AddForce(Vector3.up * yForce);
myRb.velocity = new Vector3(xSpeed, myRb.velocity.y, myRb.velocity.z);
The yForce and xSpeed variables will need to be replaced by a constant (a number) or created as variables
Your answer
Follow this Question
Related Questions
Rigidbody Enemy and Collisions 2 Answers
Calculate Angular Velocity to Match Remote Position 0 Answers
Rotate Rigidbody Towards Velocity? [3d] 0 Answers
2D metroid boost ball 0 Answers
Inconsistent Jump height 3d 3 Answers