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

GetAxis being missed in FixedUpdate work around?

$
0
0
I feel like I'm having a colossal brain fart right now, but I can't figure this out. void FixedUpdate() { moveHorizontal = Input.GetAxis("Horizontal"); moveVertical = Input.GetAxis("Vertical"); jump = Input.GetAxis("Jump"); movement = new Vector3(moveHorizontal, 0.0f, moveVertical); rb.AddForce(movement * speed); if (canJump) { rb.AddForce(0, jump * jumpHeight, 0); } } Player movement works fine but jumping is buggy. If I apply the force to jump in FixedUpdate, it gets missed sometimes if the player is jumping a lot, and also, for some reason, if the player is moving diagonally(Like maybe GetAxis is being overloaded with three buttons being pressed?!). But if I move it to Update, a. I'll have frame rate related issues in the build, right? And b. the jumping works perfect except every once in a while the player jumps much higher, which I believe is the result of the force being added twice. Maybe I'm interpreting it all wrong? I don't like using GetAxis or Unity's physics engine, there's too much going on under the hood.

Viewing all articles
Browse latest Browse all 1264

Trending Articles



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