I have a simple question that I hope an experienced unity user can help me with. I have read that onCollisionStay is called whenever rigid body is in contact with something. But when I for instance, make a ball jump in the air and it hits a platform above it, it does nothing. So when is it called exactly?
It’s just somewhat confusing the way its written. I’ve also noticed that if I were to jump and hit the side of a platform it still jumps. So it is called everytime it touches a collider? So since it hits the bottom of the platform above it and isn’t called why is this.
Here it says that when the rigid body falls to rest it starts sleeping, but if its still up in the air when it hits the above platform is it still “awake” . Sry if im abusing the terminology. It’s just hard to tell why it does what it does.
Thought about it for a while and the best I could come up with is that right after the ball makes impact, it falls asleep
So I guess that its “asleep” right after it hits an object because all its velocity is lost. Any opinions or interest? Please feel free to correct me if I missed something. I’m only interested in how the mechanics work.
as a quick note I just wanted to add that when I was experimenting with sound with onCollisionStay, I noticed that the ball would jump and then fall and make a sound upon impact. However When it hits a wall overhead, it still makes a sound, but when it lands it does not.
I was thinking this had to do with it losing all velocity upon impact and “sleeping”, as opposed to it jumping going into a rest period and picking its velocity back up while falling so that it is still “awake”. I’m not too sure how velocity works but as I said if I’m missing anything or understanding this completely wrong, please feel free to jump in.
I just wanted to correct myself really fast and state that onCollisionStay Should get called continously while in contact with an object that has a rigidbody/collider. furthermore, I believe it was the way I was implementing my code that gave me the results I had. In fact If you wanted you could actually use the (Input.GetKey()) and actually have the ball stick to the ceiling or run up the side of a wall. So that could probably be a neat idea for a game.