How to stop player moving through Walls when my room shakes (animated) ?

Ok, So i have a prototype model of a room and inside my player is floating
i added an animation to this room object (rotating and shaking) and when player reaches certain place inside this room, a TriggerEnter function is called that activates the shaking animation of my room object
but suddenly the player object seems to just pass through the wall and move out of room due to sudden shake
i tried to slow down my animation , it solved the problem but now its not looking good
i wonder if there is any better way ? like i think i need to set my player as child of my room or something ?

Do you have colliders on the player and room?

Yes , i have collider and they are working but during shaking animation , sometime player just immediately pass through wall but at slow animation speed, the colliders do work effectively but now animation /shaking is not so realistic

If your room is going to move, it needs a rigidbody, otherwise the physics system isn’t able to apply it’s movements very well.

Add a kinematic rigidbody either to the parent of the walls/floor, or to each of the walls and the floor. That should help.

1 Like

Yea, well that seems to work earlier i was not using rigidbodies component for my ROOM (more like a space station tbh) ,after i used rigidbodies component and selected isKinematic (since i don’t want it to move after collision with player object) it seems to be fine :slight_smile: thanks brother