Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Connections during speed change
#1
Hi, I ran into a problem which I just can’t figure out, although I spent a full day trying.

I use Curvy for a train game, each train and car has its own Spline Controller that I control through code. Mostly I was able to figure everything out but I have one bug I just can’t fix.

When the train + cars go over a Connection Point as I increase speed somewhere mid connection once a while a car will go to an incorrect spline.  So the whole train switches but one car will not.  This only happens once a while and only if I am increasing speed while going over the connection point.

It seems to be almost like the speed increase causes it to jump over the connection point and the car does not see it.  I checked and the cars that don’t see the connection have the same Connection Behaviour as the cars that do (Random Spline exclude current). It’s its not like a forgot to set one.  It’s just not seeing the connection point (once a while)

I thought maybe it’s related to caching or pooling but disabling both does not seem to help.  

I am using the latest version of Curvy from the Unity Store.

Thanks
Reply
#2
Hi,
Sorry for that. Can you please send me a reproduction scene?
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
Well the fact that you are asking for a repro tells me that this is not a common issue?

Maybe I am doing something wrong, I will look at your sample scene first and If I can’t figure it out I will make a repro scene.
Reply
#4
So after some additional testing, it seems that it only happens in reverse.
Reply
#5
(03-25-2019, 04:46 AM)3583Bytes Wrote: So after some additional testing, it seems that it only happens in reverse.

So the reverse thing was false, i can replicate it in both directions, however I think I may have found the issue,

In my code I simply adjust the position on the spline when needed, in the Example Scene I see that I should really be using:

SplineController.TeleportBy

I will test tonight
Reply
#6
I have a same situation, but it not depends on speed increasing. Part of the cars moves into one spline and another part into another spline. It's very strange becouse i've got this problem with one arrow only (i have very much arrows - about 30 and they work fine). I solved this problem in the editor by changing all the cars train UpdateIn method. The problem appear when it set in "Fixed Update" but when "Update" all work fine. But not in the build. How it can be that in the editor it works but in the build there is problem?
Also i think that this problem can be somehow related with the very big length of the spline, becouse this arrow is the most distanced. My spline's lengh is 18300 and this arrow on 17700.
Any ideas?
Thank you in advance.
Reply
#7
Hi,
The best way to proceed is to send me a reproduction case so I can diagnosis exactly what's going on. But if this is impossible/too time consuming, can you please tell me:
1- what is the minimal speed of the arrows
2- what is the longest segment's length of your splines
3- what is the value of your Position Mode and Move Mode fields
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#8
(04-05-2019, 10:44 AM)_Aka_ Wrote: Hi,
The best way to proceed is to send me a reproduction case so I can diagnosis exactly what's going on. But if this is impossible/too time consuming, can you please tell me:
1- what is the minimal speed of the arrows
2- what is the longest segment's length of your splines
3- what is the value of your Position Mode and Move Mode fields

I've solved the problem. 
I created a short new spline on the place of the old one near the arrow. I connected the old one and the new one and then make an arrow on the new spline connected with another. The problem dissapeared. 
Thank you for your answer. Curvy is the best plugin i worked with! Good job!
Reply
#9
(04-05-2019, 12:04 PM)talentplace Wrote: Curvy is the best plugin i worked with! Good job!
Thanks a lot, I am very happy to read this.

If I had to guess what happened based on what you said, I would say that it might be an issue related to the controller's position being stored as a float. Like you might already know, floats can't represent every possible number, so there are some numbers that are mathematically different, but are the same in the eyes of floats. So with floats, you can end up having a + b - a > b, which is mathematically false. If you want to learn more about this, you can start here: https://stackoverflow.com/questions/7539...-imprecise

So when having very big segments, and a controller that moves very slowly on them, the code that handles connections can end up with weird situations like the one described above. I have another user which send me a reproduction case few days ago (also having very long splines, and very slow objects). Based on it, i will enhance the connections handling code for an upcoming release.
For future references, here are workarounds to those kind of situation:
  • Avoid having very long segments. The subdivide tool will be helpful.
  • Avoid having very long splines. This should not be necessary if previous workaround works. The split tool will be helpful.
  • Use Relative in both Position Mode and Move Mode. Due to the nature of float values, the more you get further from 0 the less floats are precise. So to reduce the issue, make the controller work with positions between 0 and. This will mean that when switching between two splines with different lengths, you will need to modify the Speed accordingly, to keep a constant absolute speed. Spline controller has events that you can listen to, like OnEndReached and OnControlPointReached, to detect a change in spline and update the speed accordingly.
  • Use the same value in both Position Mode and Move Mode. This avoids the controller to do some conversion operations on the position value.
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
  Connections handling > change by code dazz777 5 318 03-01-2019, 02:18 PM
Last Post: _Aka_
  Connections for large splines DekoGames 6 746 01-04-2019, 11:09 AM
Last Post: _Aka_
  Pitch and Speed sirak 1 377 11-23-2018, 02:48 PM
Last Post: _Aka_
  Difficulty with connections justinms66 1 626 08-08-2018, 11:30 AM
Last Post: _Aka_

Forum Jump: