Hi there,
I’m trying to activate an animation which is associated with an object. When the Object hits the collider ‘Destroy’, the object is killed fine, but the animation doesn’t play before this. Can you help to work out how this can happen. I have the animations in the object set up and is hitting an object with a trigger selected.
void OnTriggerEnter(Collider other) {
if (other.tag == "Destroy")
{
_GameManager.GetComponent<GameManager>().Death();
Destroy(GameObject.FindWithTag("JackSteelBody"),4);
Jack.GetComponent().Play ("JackBreak");
}
The error that comes up is:
Assets/Script/Player/PlayerControl.cs(81,25): error CS0103: The name `Jack' does not exist in the current context
Many thanks for any help.
Rich
Thanks. That works. I did think though that I put a wait on the Destroy for 4 seconds. Would that not do it?
– RichCogginIf you do it in a coroutine it will, but since it's just a function it waits until it's finished before going to the next line. I also suggest instead of using a fixed delay, have your coroutine wait the “.Length” of the animation so if it gets changed later you won't have to edit the code.
– FWCoreyI'm late but, did that clear your doubt?
– GluedBrainI have been down a long and dark road and have come out the other side to find a few other challenges. I am now now watching The Lord Of The Rings which journey I am beginning to relate to. Thanks for your help. It went some way, but only part of the puzzle. As with all these projects there are many pieces to place. Stealing the words: Hobbits! [cheers abound.] "I don't know half of you half as well as I should like, and I like less than half of you half as well as you deserve." Rich
– RichCogginYou are STILL making huge assumptions Print the values IN the if... if(GUI.Button(new Rect(offset.x,offset.y,buttonWidth,buttonHeight),i.getName())){ print("offs:"+offset.x+" Screen-250:"+(Screen.width-250)); //insert useitem code } See if they are what you think they are Proper debugging means drilling down on every assumption until you find one that s not true,
– Jeff-Kesselman