- Home /
Spawn inside of a parent
Hello,
In my game I want my player to click and load a shovel into there hand. My code works fine but the shovel does not move with the hand, it stayed where it first loaded.
function Update () {
if(Input.GetButtonDown("Fire1")){
var shovel1 = Instantiate (shovel, gameObject.FindGameObjectWithTag("SpawnPoint").transform.parent.position, Quaternion.identity);
}
}
Thanks
Have you tried parenting the instantiated object to the player, player's hand, etc.?
Answer by zee_ola05 · Feb 23, 2014 at 08:42 PM
try shovel1.transform.parent = this.transform;
after Instantiating the object.
It works, thank you!
PS. some of my questions never show up. Do you know why this is happening?
When you have low karma, moderators have to screen your questions first. Sometimes, it takes time before they do. You should answer some questions too to get more karma! Yay! :D
Your answer
Follow this Question
Related Questions
Make a simple tree 1 Answer
"Center On Children" programmatically 1 Answer
Attaching a game object as a child during runtime? 3 Answers
Multiple cameras as child or assign coords/rot to main cam 1 Answer
Getting the topmost parent 1 Answer