Hi I am new in unity and I am trying to assign a prefab to a GameObject I have via script. I want to make it so that if a wheel triggers with blood there would be bloody tracks behind the car as the car moves. I have a GameObject named leftCollider with a box collider acting as a trigger which is attached to my PlayerCar. I want to instantiate my particle trail called leftbloodTrail to the leftCollider game object. I attached this script to the leftCollider:
var leftbloodTrail : GameObject; function OnTriggerEnter (myTrigger : Collider){ if(myTrigger.gameObject.tag== "Blood") { Instantiate(leftbloodTrail, transform.position, transform.rotation); leftbloodTrail.transform.parent = this.gameObject.transform; } }
When I run this code it gives me the error “Setting the parent of a transform which resides in a prefab is disabled to prevent data corruption” and the object with the particle trail does not parent itself to the “wheel position” gameObject.
Thank you in advance.