Player goes through ceiling when using Physics.Gravity. (88084)

Hello. When im adding this script to player…well its working pretty good,player is flying up,but it will not stop,its even going through ceiling,i mean rigibody which is attached to player does not detect collisions at all,player just go through walls,i need help to fix this,please someone help me :slight_smile:

Physics.gravity = Vector3(0, 50, 0);

Does your ceiling have a bounding box on it, and is the "Trigger" option deselected? Does the player move really fast? You could turn on Continuous Dynamic collisions in the rigidbody if so and try changing the interpolation setting. Also make sure the room you are standing in, is not inside of a collider.

1 Answer

1

You are changing gravity for every rigidbody in the scene, and not changing it back, unless you are planning on making a game where the gravity changes over time.

I’d say you want to make your player jump, so what you probably want to look at is Rigidbody.AddForce

Your player clips throw the ceiling I imagine because he is accelerating upwards at 50 meters/second (roughly 5x Earth Gravity, in the wrong direction), and achieves a high enough speed to act like the collider is not there.