Quantcast
Channel: Questions in topic: "addforce"
Viewing all articles
Browse latest Browse all 1264

Achieving consistent jump height regardless of vertical velocity

$
0
0
I keep my player object (Rounded cube, like dice) in steady horizontal motion by directly changing the velocity. cubeRB.velocity = new Vector3(maxVelocity, cubeRB.velocity.y, 0); Vertical velocity is unconstrained, so as it moves along the ground, it bounces and spins without slowing down. The user can press space to add a positive force to the y axis in order to jump. The problem is that since my cube is bouncing, its vertical velocity at the time of the jump is virtually always going to be negative or positive, which creates a great deal of inconsistency in jump height. I imagine to remedy this, I'll need to do some kind of math with the current vertical velocity and how high I want the cube to jump, but I don't math very well... Any ideas or a solution would be greatly appreciated. Jump code: cubeRB.AddForce(0, jumpForce, 0, ForceMode.Impulse);

Viewing all articles
Browse latest Browse all 1264

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>