Ok I'm making a FPS and I'm trying to make a script that will allow the player to pick up weapons off the floor. I do this by instantiating the weapon in front of the player and parenting the weapon to the player. Every thing work's fine but when I made the weapon a prefab it didn't work and an error message came up and it said something like "parenting a prefab is disabled to prevent data corruption". So my solution is to break the connection of the prefab in the awake function? But I don't know how to stop the prefab connection. Anything will help thanks!
var weaponHoldPoint : Transform;
var pistol : Transform;
var assualt : Transform;
function Start ()
{
Instantiate(pistol, weaponHoldPoint.position, transform.rotation);
pistol.transform.parent = transform;
}
↧