- Home /
Collision will not work
Hey guys I've put this collision code onto a bullet prefab in my game however it keeps on giving me the same response.
The error it gives me is Script error: OnCollisionEnter This message parameter has to be of type: Collision The Message will be ignored
In my scene there are objects that can be collided with because they have mesh colliers and I also have a terrain in the scene as well. here is the code.
var Target : GameObject;
var ObjectName : String = "Bullet";
function OnCollisionEnter(collision : Collision){
if (collision.gameObject.tag == ObjectName){
("Collision.gameObject.tag equals " +collision.gameObject.tag);
Destroy(Target);
Debug.Log("target hit");
}
}
So yeah someone please help because I'm running out of options that should work but don't I am also currently using the latest version of unity as well.
I have had good experiences with OnTrigger functions. Consider if these can work as a solution.
Do you think I should change the name of the collision script to something else and that might solve the issue.
ok It did do something the script is now called BulletCollision and it doesn't give me the error message anymore but it still doesn't seem to register when ever it hits anything; got any ideas.
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Collision problem 0 Answers
Creating a draggable object - and defining areas. 1 Answer
Simple Collision with children of other GameObject doesnt work 1 Answer