- Home /
My marble (Player/Gameobject) goes through the "play board" (gameobject). Why?
Hello all!
I don't really like vague question, so here comes more detrails.
I have a marble that is moving around a board. The player has no control on the ball at all, though. What will make the marble move is the board and the gravity. The player rotates the board to move the marble around the maze. The board is moved by a script I programmed myself in C#.
My problem : When the marble is not moving anymore (completely stationary) and I try to move the board, the marble doesn't detect the collision at all and stay fix in the air until I move it manually myself in the "Scene" tab. Of course, I do not want that, it should always be affected by gravity and it should never go through the floor randomly.
My question : What is happening exactly and is there a way I can fix this little problem? It doesn't stop me from programming and testing anything else I want to implement in my game, but it's still quite annoying to go through the floor with no real logical reason.
I thanks you in advance for reading all of this and hope you can help me with this little problem.
did you set the collider as continuous for the marble? Sorry I don't know! Your marble can bounce around with physics already? It has to do that at least then it should be okay, probably you are overriding the physics by having some transform position and function update? Otherwise the rigidbody should be running.
I tried, but it didn't change anything. I put it back at discrete for now. The marble can bounce around no problem and it moves, until it completely stop (on purpose on my side). When it stops, it doesn't move anymore, as if it was stuck in the air. I do not move the marble directly with the controls or with a script. Only the board is moving.
Answer by Matt-Downey · Oct 22, 2012 at 10:26 PM
Try this and attach it to the marble, so it wakes up the rigidbody:
function FixedUpdate()
{
rigidbody.WakeUp();
}
There are settings in edit-->proj settings-->physics that control when a rigidbody falls asleep (min velocity, min angular velocity, etc) but they seem to glitch too often to be reliable.
This actually totally solved the problem I had. $$anonymous$$any thanks to you, $$anonymous$$att Downey. :)
Did you have a kinematic rigidbody attached to the board and it wasn't waking up the ball?
The board does not have any rigidbody at all, only the ball has one. Also, the gameobject "board" is simply used as a parent to store all the others gameobjects that will be used to create the parkour/level layout.
Well you need a rigidbody attached to anything that has a collider that operates with physics - not having one is a significant performance penalty and leads to the problem you were having.
Should I put the said rigidbody on the parent to save time? Or that won't work and I need to put one on every single element that are in the parent?