Hello there,
I’m having trouble with instantiating a prefab and making it a child of the object that it hits. This is the error that Unity gives to me :
“Setting the parent of a transform
which resides in a prefab is disabled
to prevent data corruption.
UnityEngine.Transform:set_parent(Transform)
Bullet:Update() (at
Assets/Script/Bullet.js:39)”
and this is part of the script “interested” :
var HitHole : GameObject;
var power : int;
var HitParticleSpacing : float = 0.01;
function Update ()
{
var fwd = transform.TransformDirection(Vector3.forward);
var Hit : RaycastHit;
if (HitHole)
{
Instantiate(HitHole, Hit.point + (Hit.normal * HitParticleSpacing), Quaternion.LookRotation(Hit.normal));
HitHole.transform.parent = transform;
if (Hit.rigidbody !=null)
Hit.rigidbody.AddForceAtPosition(fwd * power, Hit.point);
}
}
I’ve someone can help me , I just don’t know what’s my error!