Quantcast
Channel: Questions in topic: "javascipt"
Viewing all articles
Browse latest Browse all 1875

Instantiated GameObject does not have variables

$
0
0
Im working on a weapon pickup and drop system but the dropped weapon clone does not allow to pick it up again because the variables arent assigned to the clone! How can I fix that? I cant use find because the variables are not defined. var wepclone : GameObject; var weapon1 : GameObject; var weapon2 : GameObject; var inTrigger : boolean = false; var picktext : GameObject; var Spawn : Transform; var wepdrop : GameObject; function Start (){ picktext = GameObject.Find("PickText"); Spawn = transform.Find("wepdropspawn").GameObject; picktext.SetActive(false); } function Update (){ if(!weapon1.active){ if(!Input.GetButton("left shift")){ if(inTrigger){ picktext.SetActive(true); if(Input.GetKeyUp("e")){ Destroy(wepclone); weapon1.SetActive(true); weapon2.SetActive(false); picktext.SetActive(false); var wepdropclone : GameObject = Instantiate(wepdrop,Spawn.position,Spawn.rotation); } } else if(!inTrigger){ picktext.SetActive(false); } } } } function OnTriggerEnter (pickarea : Collider) { if(pickarea.tag == "Player"){ inTrigger = true; } } function OnTriggerExit (pickarea : Collider){ if(pickarea.tag == "Player"){ picktext.SetActive(false); inTrigger = false; } }

Viewing all articles
Browse latest Browse all 1875

Trending Articles



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