Hello, looked through the forum and found some solutions that were close to what I want, but not quite. I’m trying to parent something instantiated, and make it a child of the object hit by the raycast. Like an arrow or bullethole sticking to something that can move. I’ve got
and that gives me a bullet hole on the surface of the object, but my next step is to figure out how to get it to move with the object it hit, so it doesn’t leave a wall of bullet holes behind if the object moves. Sorry to be filling up the forum with questions that are so basic
Thought I had it figured using Bullet_Default.transform.SetParent(shootHit.transform);, but get an error message saying Setting the parent of a transform which resides in a prefab is disabled, thats if it even would have worked
Bullet_Default is the prefab you’re ‘cloning’ as a result of the Instantiate. Just use what’s returned from that method (which is the clone itself) and set its parent instead.
var clone = Instantiate(...);
clone.transform.parent = shootHit.transform;
Put “(GameObject)” in front of Instantiate(). Or “as GameObject;” after it. When you specify a position and rotation to Instantiate it returns an Object, not a GameObject, so you must cast.