Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

Function OnTriggerEnder (difficult JavaScript)

$
0
0
------- Ok hi all my code is below and i am stuck cause i cant define the object that enters the trigger zone ------ var MonsterBody : Transform; function OnTriggerEnter (other : Collider) { if (other.tag == "Alive") { MonsterBody.GetComponent("Hostile-AI").PerceptionCollision = true; } } function OnTriggerExit (other : Collider) { if (other.tag == "Alive") { MonsterBody.GetComponent("Hostile-AI").PerceptionCollision = false; } } --------- Now in the script called Hostile-AI i have this ( which is my problem ) --------- if (PerceptionCollision == true) { transform.LookAt(Vector3(GetComponent("PerceptionArea-Trigger-AI").other.transform.parent.transform.position.x, transform.position.y, GetComponent("PerceptionArea-Trigger-AI").other.transform.parent.transform.position.z)); } -------- The error that I get is this : ----------- NullReferenceException: Object reference not set to an instance of an object Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.String cacheKeyName, System.Type[] cacheKeyTypes, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory) Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.Object[] args, System.String cacheKeyName, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory) Boo.Lang.Runtime.RuntimeServices.GetProperty (System.Object target, System.String name) UnityScript.Lang.UnityRuntimeServices.GetProperty (System.Object target, System.String name) Hostile-AI.Update () (at Assets/MyScripts/Mob AI/Hostile-AI.js:54)

Viewing all articles
Browse latest Browse all 171066

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>