playMaker

Author Topic: GetParent with EveryFrame[SOLVED]  (Read 1676 times)

MajorIdea

  • Full Member
  • ***
  • Posts: 131
GetParent with EveryFrame[SOLVED]
« on: May 15, 2019, 12:57:38 PM »
Hi,

I'm doing a Raycast that stores the Hit Object and need to get the forward vector of it's parent. The problem is it I can't get out of the state.

There seems to be no way to do a Get Parent more than once inside a state.

I've looked in the ecosystem and tried to edit the script with no success.

Would such an action be possible / a good idea?
« Last Edit: May 17, 2019, 01:32:14 AM by jeanfabre »

Thore

  • Sr. Member
  • ****
  • Posts: 480
Re: GetParent with EveryFrame
« Reply #1 on: May 16, 2019, 01:36:04 AM »
Sounds like a bad idea. Finding, and getting game objects, getting components and suchlike are usually treated as expensive and not done every frame.

You could make it so that whatever changes the parent...
  • also send an event that tells a target (or broadcast to all) that the parent changed, or maybe sets it directly in the target.
  • also set a bool variable that the parent changed, and have the listener check the bool variable and when is true, get the new parent and set the bool to false afterwards.

Another way is setting up a loop with a short wait timer. Put a wait action on top of the state, and have it send an event that routes to the same state, but be sure to set a time greater than zero.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: GetParent with EveryFrame
« Reply #2 on: May 17, 2019, 01:32:04 AM »
Hi,

ok, I made a GetParent2 on the ecosystem which will give you the everyframe option.

I do agree that this might be a bad idea, but I am also sometime confronted with this where a single state flow makes more sense and is easier to work out.

Bye,

 Jean