- Home /
Object going through (or getting inside) another object
I am having an issue where a player object goes through (or gets inside) another object every once in awhile. I have heard of a "bullet through paper" problem, but I have done everything (as far as I can tell) to solve this issue.
I set collision detection on every object in the scene to Continuous Dynamic
I made the wall very, very thick
I set max speed of the player object to 30
The most annoying part of my problem is that I do not know what parameter causes this issue. I literally have to continuously bump my player object into a wall for about a minute to have it go inside a wall.
Anyways, is there anything else I can do to try to fix this issue?
Thanks!
Answer by markmmiller · Feb 02, 2014 at 12:13 AM
How are you moving the object?
Collisions will only be calculated for the object if you move using the MovePosition, AddForce or velocity methods on the rigidbody. Using a simple vector translate is often the cause of this problem.
The other cause is to ensure that the object has colliders attached and that they are NOT set to triggers. The other one is that the rigidbody is not kinematic either.
As well as this mesh colliders cannot collide with other mesh colliders. As such for more complex objects sometimes it is better to use simple bounding boxes for the collisions as opposed to auto generated mesh colliders.
_body.velocity = new Vector3 (0, 0, 0);
float speed = $$anonymous$$athf.$$anonymous$$in (sw.speed * 0.0015f, 15);
_body.AddForce (new Vector3(sw.direction.x, 0, sw.direction.y)*speed);
This is how I am moving it. sw.speed being the swipe speed.
Also, when I make the walls not kinematic, the player object gets stuck :(
Hmm I'm not too sure then in that case.
I would probably try multiplying the speed by Time.deltaTime ins$$anonymous$$d of 0.0015f since that would make it frame independant.
Generally things only get stuck if they move too fast so I'm not too sure.
Where does the player get stuck when the walls are not kinematic?
Hmmm... when I use Time.deltaTime, it goes through the wall a lot easier -_-
Anyways, when the walls have kinematic off, the player objects goes into the wall half way, then gets stuck. It usually bounces off the wall
I learned that this happens on the 90 degree corner. I fixed the problem by placing a small wall in the middle to make two 45 degree angle. It actually looks more aesthetically pleasing anyways. Thanks for the help markmmiller!
Your answer
Follow this Question
Related Questions
Physics AddForce reduced when 3 objects are colliding 1 Answer
Custom Controller 1 Answer
Rigidbody stuck in colliders when moving and ricosheting. 0 Answers
OnCollisionEnter but have colliding object not move the object it collides with 1 Answer
Rigidbody magnitude comparison is not working correctlly? 2 Answers