- Home /
Trigger animtaion when hit
Hi guys, im not a very experienced scripter and never used c# before (actionscript 2 and little 3 only). Trying to get an object's animation to play when it gets hit by another object. i've tried to search out a solution in js and c# but none is working (getting close to c# though). Can eanyone see what im doing wrong?
using UnityEngine;
using System.Collections;
public class cowHit : MonoBehaviour {
public GameObject otherObj;
public GameObject resultObj;
void OnTriggerEnter(Collider otherObj)
{
resultObj.animation.Play("hit");
}
}
Comment
figured it out :D
had script on wrong object. and assigned gameObjects to wrong slots lol