I want my Oject to move up when it collides with “Player” ( “Player” standing on the Object, I want to make an elevator) so I write the code like in the picture. However, It works really weird. When “Player” Collide with Object, The Objet goes up but the Debug.log keeps spamming. And when the “Player” jump off, The Object also keep going up ,the Debug.log is spamming. I have no idea what is happening.
One thing I notice that when “Player” is colliding with the Objet, the Debug.log spam slower.
When the player jumps off ‘goup’ is set to false and stays false. So the debug log will message “player go off” 50 times a second. This is because FixedUpdate is run 50 times a second.
It keeps going up because you don’t set the velocity back to zero on collision exit, or alternatively in in the ‘if (goup == false)’ code block. The velocity is still set to go up until you tell it to stop.
