playMaker

Author Topic: Position an object in the center of multiple objects in array list?  (Read 996 times)

justifun

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 285
I have an array list with a list of objects.
I'd like to position another object in world space in the center of where all of those game objects in the list are in world space.  Kind of like a group center of mass.

I was attempting to use the array list get next action to cycle through all of them and move the object halfway between the previous objects location via a vector3 lerp. but i'm running into the issue of the array list get next needing to loop every frame and never exit without creating a infinite loop.

How might I approach this?
thx

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: Position an object in the center of multiple objects in array list?
« Reply #1 on: June 30, 2023, 10:54:14 AM »
Hi.
you can add a Next Frame event to prevent a infinite loop.

you can also do the Lerp in a separate fsm, if you need it to stay in a same state.

another way is to use a Tun Gsm with a template to do the loop inside, so you can do the lerp in the same state