playMaker

Author Topic: Animating or transforming positions of child objects  (Read 1437 times)

unearthly

  • Junior Playmaker
  • **
  • Posts: 62
Animating or transforming positions of child objects
« on: April 26, 2017, 10:21:49 PM »
Hi,

I have a group of objects parented to another which patrols using way points and seeks the player. All works fine.

Anyone with suggestions of how I might be able to move the children (birds) from their current v shaped flock formation to cluster equidistant around the player, in an attack mode, then return to their original formation in the patrol mode?

jasperPT

  • Full Member
  • ***
  • Posts: 115
  • I am a VFX Animator teaching myself to make games
Re: Animating or transforming positions of child objects
« Reply #1 on: April 27, 2017, 01:59:08 AM »
Sure.

Couple of ways you could do it depending on what behaviour you want.
Let's say you wasn't it like this

Parrolling formation > found target > move to target  > surround target and attack> move back to last patrol position and reform formation.

So for each bird in the formation you would need a position that the bird should be in, stored in an array, for something like a V formation that would be pretty simple to set up in a seperate FSM, so if any birds die it could re calculate the formation and they would each reference the positions they need to go back to.

For the part where they go and attack, first thing is to store the position of the parent (the part that is patrolling) so it knows where to come back to. Then make it move to the player holding the birds. While it is moving you could do a similar thing as the above formation FSM to create a "moving to attack" animation"

Then once you get to the player you need to effectively make a new formation as a circle around the player. To get positions in a circle around something, you can do fancy maths, or you can do it the hack way like I would:

Have an empty object (call it targetCenter)with an empty child under it. (Call it  Targeter)

The Targeter move the targeter out to the distance you want your circle's radius to be. Put targetCenter at the player> count how many birds there are > divide number of birds by 360 > rotate the targetCenter by intervals of this number, storing the position of the Targeter at each interval until you have Rotated a full 360.
You now have local positions that will form a circle around your target.
Use them to effectively create a new formation as you are attacking, the parent of your birds could just be following the player closely or even parented somewhere under the player.

Once they are done attacking they do the above but in reverse, moving back to their original position and continuing to path.

unearthly

  • Junior Playmaker
  • **
  • Posts: 62
Re: Animating or transforming positions of child objects
« Reply #2 on: April 28, 2017, 11:30:33 PM »
Thanks jasperPT.

Had a look at Arrays and frankly couldn't see how they might help more than the  iTween Move To actions I have be trying to use. I tried them again and I must have made a small error before cause, it's working like a dream now. I have used a similar approach to the one you described for getting each birds attack position.

Your description of what I needed to do did help clarify the steps needed. Thanks again for taking the time.