hi all
my game is fps shooter and i create full body controller
i have 1 gameobject i called GunPlace (on right hand)
and i have guns
i want when press “F” button , gun child of GamePlace and i can gun Transform change (i can set Transform and rotation for fix place)
give me this error :
UnassignedReferenceException: The variable Gun of ‘GunPlace’ has not been assigned.
You probably need to assign the Gun variable of the GunPlace script in the inspector.
GunPlace.Update () (at Assets/scripts/GunPlace.js:9)
and fixed but
I do not understand Gun.parent , Gun child and gunPlace is parent or gunPlace is child and gun is parent ?
cuz fixed with code and gun attach to gunplade (maybe unlike ) because gun are bad place
the property “parent” of “Gun” is set to the transform the script is attached to:
The gun is the child of gunPlace (which has the above code attached to it).
from the localPosition reference page
// Move the object to the same position as the parent:
transform.localPosition = Vector3(0, 0, 0);
“this.transform.position” is the offset of gunPlace from the center of the world, “transform.localPosition” is the offset of gunPlace from it’s parent object. If you use either of these as the Gun’s localPosition you’re going to end up with the gun being far from the gunPlace position.
and this erro :
UnassignedReferenceException: The variable Gun of ‘GunPlace’ has not been assigned.
You probably need to assign the Gun variable of the GunPlace script in the inspector.
GunPlace.Update () (at Assets/scripts/GunPlace.js:9)