Hi,
I am trying to make a game like Frogger. When you jump on the log you move with log.
So I created a Prefab that's randomly being called and it move down the river.
My issue when I jump on the log, I get an error message saying :
Setting the parent of a transform which resides in a prefab is disabled to prevent data corruption. UnityEngine.Transform:set_parent(Transform)
Here is the code to Instantiate the prefab:
var prefab:Transform;
var Platform:Transform;
function appear () {
var position = Vector3(Random.Range(74.4, 76.2), 2, Random.Range(-8,-7));
var Platform= Instantiate(prefab,position, Quaternion.identity);
Here is the Parenting Code it is on the Player, The prefab is tagged as Platform :
var myplatformSides:GameObject;
function OnControllerColliderHit(hit: ControllerColliderHit) {
if(hit.gameObject.tag=="Platform"){
transform.parent=myplatformSides.transform;
}
else
transform.parent=null;
}
Thank you