playMaker

Author Topic: Add time delay to Vector3  (Read 3017 times)

dasbin

  • Junior Playmaker
  • **
  • Posts: 92
Add time delay to Vector3
« on: January 13, 2012, 10:09:15 PM »
The "Wait" action is not working for me here, and I can't logically figure out how to otherwise do this.

Basically, I am getting the velocity of an object, then applying it to a different object, but with a 1 second delay between then. So whatever object A did 1 second ago, object B will do now.

Using the Wait action just results in a single velocity being sent every 1 second, rather than a smooth stream of data that is 1 second delayed.

Any ideas? I'm a bit of a newbie. Thanks.

dasbin

  • Junior Playmaker
  • **
  • Posts: 92
Re: Add time delay to Vector3
« Reply #1 on: January 13, 2012, 10:13:51 PM »
And a secondary question, a bit more "duh" showing how bad I am at Unity :)

I'm guessing this should include a "Vector3 per second" Action, in case the frame rate has changed between when object A moved and when object B should move. But I'm not certain where in the sequence of events to make this multiplication, or how to get it back to a useable velocity for object B.

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3987
  • Official Playmaker Support
    • LinkedIn
Re: Add time delay to Vector3
« Reply #2 on: January 14, 2012, 08:20:16 PM »
The Wait action just delays the FINISH event on a state so it won't help you in this case.

Ideally you'd use Send Event with a delay of one second and use Set Event Data to store the velocity. Then when the other FSM gets the event it can use Get Event Info to retrieve the velocity.

However there are a couple of problems with this approach:

1) Just found a bug with Set Event Data and delayed events. So that won't work  :'(
2) Send Event doesn't have an Every Frame option since this wasn't an anticipated use case. However you can use a Next Frame Event to loop the state...

Anyway, this is an interesting problem! I'll fix 1) above and test your scenario in the current beta. That would make this sort of thing easy to do - which I like :)

There's probably other ways to do this, maybe storing a buffer of velocities using ArrayMaker...?

dasbin

  • Junior Playmaker
  • **
  • Posts: 92
Re: Add time delay to Vector3
« Reply #3 on: January 14, 2012, 08:29:13 PM »
Great; thank you for looking into it!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Add time delay to Vector3
« Reply #4 on: January 18, 2012, 03:13:45 AM »
Hi Dasbin.

 If you plan on using ArrayMaker, don't hesitate to let me know if you have issues or problem to set it up.

If you do need a stream of data, then yes, arrayMake will be your savier :)  If you do only need to store the position one second ago, I think you do not really need an array, since only one variable is enough and if on each gameObject you have an fsm responsible for that, then you are ok when using prefab.

Bye,

 Jean