- Home /
object isn't detecting collisions
so I have this script
var NifeDamage = 60;
function Start () {
Throw();
}
function Throw(){
GetComponentInParent.<Rigidbody>().AddForce(transform.parent.forward * 1000);
GetComponentInParent.<Rigidbody>().useGravity = true;
GetComponentInParent.<Animation>().Play("Nife");
}
function OnCollisionEnter(collision : Collision){
Debug.Log("Hit something");
GetComponentInParent.<Animation>().Stop("Nife");
}
in theory it should stop the Nife animation when detecting a collision but for some reason it just keeps repeating the animation over and over the animation is set to loop but I don't know how to keep the animation going through scripting does anyone have a idea?
also the log isn't returning Hit something either and the nife is using a mesh collider and is convex
Is the collision being registered? Does "Hit something" get printed to the console? What rigidbody/collider settings do you have?
no hit something is not getting printed and for the collider settings the nife itself has a mesh collider and is convex but the objects that its colliding with arent convex but they don't have to be if im right because only 1 of the objects needs to be convex when using a mesh collider
the nifes rigidbody is the normal settings of a rigidbody but gravity is off til the script starts running as you can see(this due strange movement behaviour when it being on when the script wasn't running)
Right, so your problem has nothing to do with animation then, and your animation loop settings are irrelevant.
So, you have: - Object A with convex mesh collider and rigidbody (not kinematic) - Object B with non-convex mesh collider?
Answer by yvyv1000 · Aug 02, 2016 at 12:00 PM
fixed it by making it a trigger and then using a small box collider not set as trigger to keep it from going through stuff