Posts: 4
Threads: 1
Joined: Feb 2019
03-24-2019, 02:50 PM
(This post was last modified: 03-24-2019, 02:51 PM by 3583Bytes.)
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
Posts: 2,110
Threads: 92
Joined: Jun 2017
Hi,
Sorry for that. Can you please send me a reproduction scene?
Please consider leaving a
review for Curvy, this helps immensely. Thank you.
Available for freelance work—feel free to reach out.
Posts: 4
Threads: 1
Joined: Feb 2019
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.
Posts: 4
Threads: 1
Joined: Feb 2019
So after some additional testing, it seems that it only happens in reverse.
Posts: 4
Threads: 1
Joined: Feb 2019
(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
Posts: 2
Threads: 0
Joined: Mar 2019
04-05-2019, 10:03 AM
(This post was last modified: 04-05-2019, 10:03 AM by talentplace.)
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.
Posts: 2,110
Threads: 92
Joined: Jun 2017
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 helps immensely. Thank you.
Available for freelance work—feel free to reach out.
Posts: 2
Threads: 0
Joined: Mar 2019
(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!
Posts: 2,110
Threads: 92
Joined: Jun 2017
(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/753948/why-is-floating-point-arithmetic-in-c-sharp-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 helps immensely. Thank you.
Available for freelance work—feel free to reach out.