Hi.
I have been wondering for a while, how do I make an enemy leave footprints behind him, where he walked. I have been thinking of doing an invisible enemy, with no model at all, and he would only leave footprints (textured planes) behind him.
This is what I got so far:
var footprintLeft : Transform;
var footprintRight : Transform;
var footstepSound : AudioClip;
var transformRotation : Quaternion;
function Update () {
transformRotation = Quaternion(transform.rotation.x, -transform.rotation.y, transform.rotation.z, 0.0);
//in the actual script, I check here if the enemy is chasing me, simply by using a boolean that activates when chasing
DoFootprints();
}
function DoFootprints () {
//here I put the if statement that checks if the enemy is currently chasing the player (in the actual AI script)
yield WaitForSeconds(1);
Instantiate(footprintLeft, transform.position, transformRotation);
audio.PlayOneShot(footstepSound);
yield WaitForSeconds(1);
Instantiate(footprintRight, transform.position, transformRotation);
audio.PlayOneShot(footstepSound);
yield WaitForSeconds(1);
DoAgain();
}
function DoAgain () {
DoFootprints();
}
I did the Quaternion thing, because the footstep textures were turned the wrong way. As of now, the script makes footprints and sounds, but it makes them too quickly. Maybe because I am calling it in the Update() function?