Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Timing problems
#1
Hi, I got this problem, which I think, is caused by the order scripts are run. The spline and the controllers are set to fixed update. (I'm using Playmaker too)

I have a FSM loop that once you press play will spawn from a pool and attach prefabs to a spline. It spawns a prefab and sends variables to its controller all in one frame. On the spawned prefab I have a FSM that runs when the object is spawned, that assign the sent variables to the spline controller. This also happens in the same frame.
Once the spline is full, the spawn FSM moves on to spawn new prefabs as the others move along the spline. Once the last spawned prefab has reached a point, the next one is spawned and setup in the same frame.

This works for a few spawns then it breaks. The new spawns can end up anywhere on the spline, then it works, then it breaks again. I thought it used the saved position from the prefab, but setting it to 0 didn't help. Which is odd since it attached to the spline and set speed etc. to the correct values.

I tried to add a wait so it didn't didn't read the position of the last spawn until a few frames later, in case it spawned too fast. Didn't work.

After looking for a while -I think- the once that broke are once that are spawned from the pool, despawned and then spawned again. And I think this causes a change in the order "some" stuff are run on the prefab.

I then I tried to add a one frame delay on the newly spawned prefab, so it setup itself one frame after it spawned. That kinda fixed it. The spawns that broke now works but the once that didn't brake now spawn with a one frame delay. So now everything is desynced.

This is no good. It's very important that I have frame perfect timings for these things. And what if it decides to break during the initial spawn? Maybe it will vary on different computers. It's crucial that I can assure the same things happens on the same frame every time, all the time.

This became a bit long, but the question is, do you have a suggestion how I can make sure the controller does its thing only "after" the spawn FSM has finished, without having to resort to frame delays? Like I said, I require frame perfect precision for this.
Thanks.
Reply


Messages In This Thread
Timing problems - by Lupp_ - 01-12-2021, 12:40 AM
RE: Timing problems - by _Aka_ - 01-12-2021, 07:56 AM
RE: Timing problems - by Lupp_ - 01-12-2021, 03:51 PM
RE: Timing problems - by _Aka_ - 01-13-2021, 10:40 AM
RE: Timing problems - by _Aka_ - 01-15-2021, 05:11 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Problems compiling after pulling down project from source control obscurelyme 2 13 02-13-2022, 03:47 PM
Last Post: Marco Schultz
Question How to tell if a spline is straight? / Optimize problems with straight splines MarioBag 3 21 12-27-2021, 05:25 PM
Last Post: _Aka_
  Problems with spline prefab topquarkone 3 436 09-15-2021, 08:47 PM
Last Post: _Aka_
  Splines Connections Problems UsernameHed 4 4,310 07-20-2019, 03:12 PM
Last Post: _Aka_

Forum Jump: