x


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");
     }
     
 }
more ▼

asked Apr 21, 2012 at 11:12 AM

silvereon gravatar image

silvereon
0 6 4 7

figured it out :D

had script on wrong object. and assigned gameObjects to wrong slots lol

Apr 21, 2012 at 09:17 AM silvereon
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

what did you attach it too out of interest?

more ▼

answered Mar 18, 2013 at 09:50 PM

No1Survivalist gravatar image

No1Survivalist
61 12 14 21

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x6939
x4310
x3026
x1787
x598

asked: Apr 21, 2012 at 11:12 AM

Seen: 1997 times

Last Updated: Mar 18, 2013 at 09:50 PM