PlayMaker Help & Tips > PlayMaker Help

Instantiating a prefab as a child of another game object[SOLVED]

(1/2) > >>

MP:
I've attempted to use the Create Object Action to instantiate a prefab as a child of another game object, and then use that game object to set the prefab's Spawn Point.

Since the prefab is a weapon, and I'm attaching it to the first person controller, I want it to stick out a bit from the body. I set a position and rotation in addition to the Spawn Point to achieve that.

When I hit play, though, things go awry. The prefab is not in the correct location, and the rotation is off. What am I doing wrong?

Thanks.

jeanfabre:
Hi,

 It's likely that you need to manually set the position and rotation to achieve a proper placement. Have you tried that?

bye,

 Jean

MP:
Well, I used an empty game object as a placeholder for the weapon which would become the prefab. I then set the weapon's local position and rotation to zero, and then moved and rotated the empty game object around so that the weapon was where I wanted it. Then I saved the weapon as a prefab and deleted the weapon from the scene.

When I tried to use the placeholder as the spawn point of the weapon prefab, however, the position and rotation for the instance of the weapon came out all wrong.

So, as far as I can tell, I've tried to set it manually, without success. Did I do something wrong in setting it manually?

Thanks for your help.

jeanfabre:
hi,

 It's difficult to say without some screenshots or actually have the fsm to look at it and debug it.

bye,

 Jean

MP:
Sure, here is a shot of the FSM and the arrow (prefab) it has positioned in outer space.

I have attached an FSM to the "Players_Bow" prefab and used the location of the Players_Bow prefab as the location where I would like the arrow prefab to instantiate. The Players_Bow prefab has already been instantiated in the attached scene, and the state "Fire_Arrow" during which the arrow prefab is instantiated at the Players_Bow location is now active.

Rather than instantiating the arrow at the Players_Bow location in world space, it seems that it has instantiated the arrow very near to what the Players_Bow's local location, taken as a world location, would be, i.e. close to world 0,0,0, way out in outer space.

I don't know how to tell the FSM to instantiate the arrow at the Players_Bow's world space.

Thanks.



Navigation

[0] Message Index

[#] Next page

Go to full version