- Home /
Question by
Brett 1 · Feb 08, 2011 at 08:24 PM ·
gameobjectraycasthitbce0019
gameObject not a member of UnityEngine.RaycastHit??
I keep getting this error..
'gameObject' is not a member of 'UnityEngine.RaycastHit'.
Here is my code..
import UnityEngine
import System.Collections
class door(MonoBehaviour): rayCastLength = 5 def Update(): hit as RaycastHit
if Physics.Raycast(transform.position, transform.forward, hit, rayCastLength):
if (hit.collider.gameObject.tag == ("door")):
hit.gameObject.animation.Play("door_open")
Anyone have any answers. BTW, I'm following the VTC Game Development with Unity DVD
Thanks
Comment
Answer by Mike 3 · Feb 08, 2011 at 08:31 PM
RaycastHit doesn't have a gameObject property, only collider and transform - use hit.collider.gameObject.animation like you do the line above it, or hit.transform.animation