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
#2
Curvy Splines' scripts are all initialized by the end of their Start method, and in some cases even earlier, by the end of the OnEnable method. The only exception I am aware of is the Curvy Generator, which has a frame delay.
I don't have much experience using PlayMaker, so I am not familiar with its execution order. Try modifying the execution order of the relevant scripts to make your FSM assigning values to the controller run after the controller script, this might fix the issue. If not, try inverting the order, who knows. If still not working, please send me privately a reproduction case and I will try to find a solution.
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#3
I did try to change the script order a bit. I didn't dare to change the order you've setup for Curvy though, since I didn't know how to restore the order if it messed up. Also, Playmaker does not show up in the list so I guessed it runs in default time. But I did move the controller script to after default and that made some changes. It still broke but it behaved differently.

I can send it to you if you don't mind the trouble, but it will have to include this: https://assetstore.unity.com/packages/to...ity-121174 or it won't work. It also have to include some ecosystem actions too. Is this ok?
Reply
#4
About restoring the order, next to each entry in the ordering window there is a number. Write down those numbers, and set them again to restore the order.

Can you please modify your reproduction case to make it not use that pooling package, but just instantiate the prefab the regular Unity way? And about the ecosystem actions, I believe they are all free, right? So no issue in sharing them.
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#5
For future reference, the problem was not due to Curvy Splines
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Splines Connections Problems UsernameHed 4 2,850 07-20-2019, 03:12 PM
Last Post: _Aka_
  Problems by upgrading from Curvy 2.2.2 to 2.2.4.1 metroidsnes 2 3,692 05-06-2018, 07:32 PM
Last Post: _Aka_
  Dynamically Generated Spline Problems ricardo@fivebits.gs 1 3,391 04-05-2017, 06:26 PM
Last Post: Jake
  CurvyEvents problems in AOT environment johnnemann 5 5,799 07-10-2016, 10:06 AM
Last Post: Jake

Forum Jump: