- Home /
Collision Being Ignored
I've made a script where a cylinder moves at random around the map, however, the cylinder seems to ignore the colliders in my walls. Any ideas why this might be?
Script:
Script:
Answer by bluethunder3991 · Jan 23 at 07:14 AM
I think the issue is due to lerp being too fast, check out this answer and see if it works. https://answers.unity.com/questions/639529/handling-collision-with-fast-lerp.html#:~:text=Problem%20is%2C%20when%20you%20move,bottom%20point%20where%20you%20entered.
Try moving the rigidbody instead of the transform.
Answer by privatecontractor · Jan 23 at 06:12 AM
Hi @Cdweave,
(1) Man check did you not missing Rigidbody Component on Cylinder GameObject?
(2) I understand form your question that object is able to move/lerp move through script) so even weird line with t= t*t*t*t... is correct, and script is fine...
Answer by Captain_Pineapple · Jan 23 at 05:22 PM
The issue with your current approach is the way you move your object.
Basically when a rigidbody does not move it falls asleep. (Literally called "sleeping"). The issue is now that when it is sleeping it will not check for collisions. When you set a new Position by transform.position = somevector
it will set a new position to the object but it will NOT wake up the rigidbody to tell it to get to work again. When you move it by rigidbodyReference.MovePosition(....)
it will wake up and check for collisions.
So when you change this to take this other method to apply the position change it should work.
SIDENOTE: This should be done in FixedUpdate instead of a Coroutine.