Question by
evil_genie · Nov 20, 2015 at 08:28 AM ·
javascriptgameobjectvariableweaponassign-variable
Trouble assigning Gameobject to variable in separate object
Hello,
I have a weapon object that can be picked up with "E" and once equipped it should fill in a space called right hand on a list of variables i have attached to the player. I've looked this up many times and no matter what I try nothing works. No errors, the variable just stays null. Please, if you have any idea what I am doing wrong I would greatly appreciate the help!
Here's the code that should be doing the job ( JS ):
if (equipped)
{
//sorry about the mess
transform.parent = righthandspace.transform;
transform.localPosition = rightHandPosition;
transform.localRotation = rightHandRotation;
this.attachedRigidbody.useGravity = false;
targetScript.RightHandSlot = self;
//here are the problem lines
player.GetComponent(carryslots).RightHandSlot = this.GameObject;
self.tag = "CurrentWeapon";
}
P.S, It should also be setting the tag of the weapon object to "CurrentWeapon" when equipped, but that isn't working either. If you can help with that too that would be awesome! :)
Thanks!
Comment