- Home /
Object reference is null
In this part of my script, the script component GunRank is in the object tagged Weapon. It cant seem to identify rank as existing even though it clearly does. Any ideas?
Comment
Seeing your script is necessary to try and figure out the problem.
Sorry guys.
function OnControllerColliderHit(hit : ControllerColliderHit){
if(hit.collider.tag == "Weapon"){
var rank = hit.collider.GetComponent(GunRank);
if(rank != null){
if(rank.primary && primary == false){
hit.transform.parent = ThrowDestination.transform;
primary = true;
}
if(rank.secondary && secondary == false){
hit.transform.parent = ThrowDestination.transform;
secondary = true;
}
if(rank.thirdweapon && thirdweapon == false){
hit.transform.parent = ThrowDestination.transform;
thirdweapon = true;
}
else
WeaponThrow = "nope";
}
}
}
Your answer
