hi i have a problem with my game i have a GUITexture as my health bar and i want the pixcelInset.width to go down by 10 when my player collides with “enemyFire”(my bulletPrefab)
the code i am using is:
//to go on player
static var gotHit = false;
function OnTriggerEnter(hit : Collider)
{
if(hit.gomeObject.tag == "enemyFire")
{
gotHit = true;
}
}
//to go on GUITexture
function Update ()
{
if(Interaction.gotHit)
guiTexture.pixelInset.width -=100;
}
//interaction is the name of my player script and i want the if statement to reference the static variable gotHit which is a true of false.
but when i try this script it comes up with :
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)
Interaction.OnTriggerEnter (UnityEngine.Collider hit) (at Assets/script/Interaction.js:5)
any suggestions?