- Home /
Collider not detecting collision with moving object
So, I have a moving object, and my player has a rigidbody.
The moving object (which has a box collider on it) just goes straight trough the player. It doesn't detect the player and the player doesn't detect the box, UNTIL i move the player. Then it detects the box and does what it should. But i need the box to detect the player even if the player isn't moving. How would i do that? Current Code :
void OnCollisionEnter(Collision coll)
{
Debug.Log("Collided with : " + coll.gameObject.name + " It has the tag : " + coll.gameObject.tag);
if (coll.gameObject.tag == "Car")
{
Kill();
}
}
Did you tried to implement the inverse case by attaching this behaviour on moving object ? and also, try making Collision Detection = Continuous
ins$$anonymous$$d of Discrete
.
Collision detection to continous didn't work, and i don't know what the other thing is :/
Answer by Major0 · Aug 10, 2015 at 03:26 PM
Here's a checklist:
Both the Player and the Car have Rigidbody component on them.
Make sure
IsKinematic
in Rigidbody component is set to false on both the Player and the Car.You're using the physics engine (e.g.
AddForce
) to move the objects, but not modifying their Transform (e.g.Translate
).
I had no idea the car needed a rigidbody too, Ï thought he just needed a box collider? o.O Anyways, thanks so much! First thing worked!
My problem is player and car(or whatever) have rigidbody and not checked iskinematic but I use just this to move:
void Start()
{
transform.position = new Vector3(0.15f,3.2f,2.05f); // just for initial placement
GetComponent<Rigidbody>().velocity = new Vector3(-5,0,0);
}
Your answer
Follow this Question
Related Questions
Collision of a moving object with a standard 3rd person controller 1 Answer
UNET Players are movable on collision 2 Answers
Object move without an input 1 Answer
Moving Platform Collisions with Custom Movement Script 0 Answers
Making the object collide while moving in the forward dir. (Vector3.forward) 1 Answer