Hi, I only started learning to script about a week ago so I’m honestly not too knowledgeable yet. I’ve watched a few tutorials and compiled a small 3D platforming script. I added gravity in a fixed update function so I could add a variable to better control the gravity of the player. Because of this I have turned off the gravity on the Rigidbody component. The gravity works fine, however I have started having issues with unity not always registering the jump button even if the player is grounded.
If anyone has any idea where my issue lies I would greatly appreciate the help.
The above is a complete mishmash of manipulating the transform directly, both rotations and positions, and setting the Rigidbody velocity, and ALSO setting force. I’m surprised anything works at all!
With Physics (or Physics2D), never manipulate the Transform directly. If you manipulate the Transform directly, you are bypassing the physics system and you can reasonably expect glitching and missed collisions and other physics mayhem.
Always use the .MovePosition() and .MoveRotation() methods on the Rigidbody (or Rigidbody2D) instance in order to move or rotate things. Doing this keeps the physics system informed about what is going on.
Pointing me to the .MovePosition() seemed to be just what I needed. Another quick question on this however. Is it always best to put the movement in the fixed update function? While testing I saw that I needed to put “Jump” in the regular Update function in order for it to work, so I wasn’t sure if it was just the movement that should be in there.