playMaker

Author Topic: After 1st pooled Prefab is spawned, position of children goes outta whack...[SOL  (Read 884 times)

curb47

  • Sr. Member
  • ****
  • Posts: 256
Sorry for the confusing title...

I'm setting up an enemy wave manager, and I've stumbled into a problem that I can't work out.

I have a Prefab consisting of one Parent game object with 6 empty game objects as children, positioned in a hexagonal arrangement. These 6 objects are spawn points.

This Prefab is one 'squad' of Drones (enemies). When the prefab is first spawned, an FSM on the prefab creates an Array from the children, and spawns a Prefab of the drone at the position of the game object children:



However, when the second, third, fourth etc 'squad' prefab is spawned, the position of the game object children, and/or the actual drones is wrong. What I really don't understand is why the position of the empty game object children would have changed.

In the image below, is the 2nd 'squad' immediately after spawning. You can see there are 2 drones that have completely spawned in the wrong place, and you can also see that all the children (spawn points of the drones) have moved away from the centre of the Parent (selected Axis).



The two small grey spheres are just my visual reference points for the game object children / drone spawn points.

The Parent is always meant to be at the centre of the 6 spawn points.

Here is a screen grab of the Drone spawner, which is on the Parent:



Can somebody help me out here and tell me where I'm going wrong?

Many thanks,

J.



« Last Edit: February 05, 2021, 02:51:14 AM by curb47 »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Hi.
Are they moving.

If you despawn you might need to set the velocity to 0,0,0 before despawning.
Not sure if this is the case in your issue.
But i had this issues with some moving objects before, the object did not have any velocity action but did get moved by a explosion and when it respawned it was still moving.

curb47

  • Sr. Member
  • ****
  • Posts: 256
Hiya,

Yes, they are moving. The Parent has a Move Towards action, which targets the mothership, and when you start shooting the drones they de-parent, and Look At the player spaceship, and have a force applied, so essentially they chase you around.

I'll try what you suggest. Thank you.

curb47

  • Sr. Member
  • ****
  • Posts: 256
Well that was a simple fix! Thanks djaydino!

Yes, setting velocity to 0, 0, 0 before despawn has done the job.
« Last Edit: February 05, 2021, 10:54:12 AM by curb47 »