Hi, I’ve used the search, but can’t find a solution to this. If it’s already been answered, I apologise.
I’m trying to instantiate a gameObject as a parent of the CharacterController. I’m building a parachute, and when it’s instantiated, with a rigidbody and drag, I’m hoping it’ll slow the descent of the character.
So far, I’ve got the triggers and scripts set so the character will fall to his death, unless the right button is pressed. The parachute is at present very small and hidden inside the player, the trigger and button press starts the animation to grow and move the canopy, This works, but obviously the rate of descent doesn’t change, and I can’t think of a way to do it other than delete the existing parachute, and just instantiate it at the right time as a rigidbody, as parent of the player.
I hope this is clear enough, and somebody can help me please!
Thanks in advance
Ian
1 Answer
1GameObject go = Instantiate(parachute, playerObject.transform.position, Quaternion.identity);
playerObject.transform.parent = go.transform;
This will set the new object as parent for you playerObject.
Exactly what I was looking for, thank you so much! :) I'll try it when I get a free minute, thanks again :D
– husbandofemilyDon't forget to stop your manual gravity in your CharacterController's script or the character controller will "fall out" of your parachute gameobject. Oh and btw. the example above is in C#, just in case... ;)
– Bunny83