OK, Still can't seem to get this to work!
I have my UFO that takes off from a hill top and bout midway through the flight through animation events I have a mid-air explosion that knoks the UFO off trajectory so it crashes on the otherside of a hill range... all works wonderfully right down to the Instantiated UFO dead replacement wreck .... Mmmm Lovely ;)
Now what I'm trying to do is add another Animation event that will drop off an "Alien Artifact" at an exact location (Which is very close to the crashed and wrecked UFO)
I thought I might be on the right track with how I was coding it but I'm not. so if someone could take a look at my script and point me in the right direction that would be great.
Edit UPDATED CODE With Comment tags:
var explosion : GameObject;
var wreck : GameObject;
var artifactTarget : Transform;
function ExplodeUFO() //Animation Event that creates the mid air explosion
{
Instantiate(explosion, transform.position, transform.rotation);
}
function KillSelf () { // Animation Event that replaces the UFO with the wrecked UFO & alien corpse
yield WaitForSeconds(3);
var wreckClone = Instantiate(wreck, transform.position, transform.rotation);
Destroy(gameObject);
}
function dropArtifact () { //Animation Event that is SUPPOSED to drop of the Alien Artifact object that the player
// can pick up
var artifactPosition = Vector3(276.7286, 5.241356, 963.852);
var artifactRotation = Vector3(270, 0,0);
var Artifact01 = Instantiate(alienArtifact artifactPosition.position, artifactRotation.rotation);
//Instantiate(artifactTarget);
print("Artifact created");
}
transform.position + Vector3(276.72, 524.13, 963.85) without the extra period
– DaveADid the code in your last edit not work either? If not, the only thing I see possible off hand is if you didn't assign artifactTarget and/or alienArtifact
– DaveALooks like you need to asign the transform in the inspector, just drag and drop the object your using to work out the vectors onto that slot. You don't need: var artifactPosition = Vector3(276.7286, 5.241356, 963.852); var artifactRotation = Vector3(270, 0,0); If you are taking the object based approach.
– anon73128419oh also add: print("Artifact created"); to your dropArtifact(). This will let you check that the function is being called (look in the log or at the bottom of the unity window ;))
– anon73128419Dave & demize it's not letting me assign my artifact it keeps giving me this error: Assets/Misc Scripts/UFOanimationEvents.js(22,23): UCE0001: ';' expected. Insert a semicolon at the end. And there IS a ";" at the end so I don't know what it's blithering on about :(
– anon48034950