I am pretty new to scripting, and i wanted to make a shooting demonstration scene. I have the weapons, the reloading system, etc… But do anyone know what do i need to write in a script that would make the following:
I have an enemy, and it obviously have colliders. I have a bullet that is nothing more than an invisible cube with physics and his own collider. I want to make something that when my bullet hits the enemy, it plays an animation. How do i do that? I have a script that i made, but as i don’t know what to write next, i don’t know if it would fit.
#pragma strict
var Bullet:Rigidbody;
var itsahit = false;
function OnTriggerExit (o:Collider) {
itsahit = true;
}
function OnTriggerEnter (o:Collider) {
if (itsahit == true) {
GetComponent.<Animation>().Play();
}
}