# Question Burst vs Non-Burst Dots Code - Seeing Different Behaviour

Discussion in 'Burst' started by mk1987, Feb 19, 2023.

1. ### mk1987

Joined:
Mar 18, 2019
Posts:
53
Bit of an odd one, i have a motion system in dots that controls a space ships thrusters and in this scenario allows it to make a smooth turn around a defined turn axis. The current code when run in Burst, is pretty much bang on a circular radius (this is done via newtonian physics so not displacement/Velocity driven), however when i wanted to debug something i disabled burst and the behavior is completely different, the ship gets to the point at which i want it to make a smooth turn and it ends up making a rounded square in effect. Spent a few hours till i realized it was only when i turned on/off burst that the problem occurred.

In one sense the right behavior is the burst one so you could argue its not a problem, but just for my own sanity (and so i can debug it effectively) could someone hypothesize why i might be seeing different results and if this is common? I'm using the unity.mathematics library 1.2.6 with burst 1.6.6 and 0.51 dots (I have yet to brace moving on to 1.0 as I'll have to rewrite all my authoring and change methodology). I cant really show a code sample as its too large to share and in any case works.

Ive not really come across such a huge repeatable difference between burst and non-burst results before, in particular with burst being the right ones!

### Unity Technologies

Joined:
May 2, 2019
Posts:
283
Hi @mk1987 - it's hard to know for sure without seeing the code, but: I would expect some amount of difference between Burst / Mono in floating point calculations. For example Mono does all its floating point calculations with 64-bit doubles and casts the results back to a 32-bit float. Out of interest if you do an IL2CPP build, does the ship's movement look like more like Mono or more like Burst?

I'm surprised you're seeing such a large difference though.

3. ### mk1987

Joined:
Mar 18, 2019
Posts:
53
I haven't tried a IL2CPP build in a while as for whatever reason it proved unreliable for my game as it was a lot more prone to crashing, i do intermittently give it a go so might do it later. I did get round the issue in the end, i think what was happening was the code that was running generated some NAN numbers (i cant exactly remember the cause), I fixed that and the problem went away and behavior is the same.

It could be the case although i have no easy way of checking that the NAN were occuring in MONO only, in this case the ship would not generate thrust while for the Burst version it was seemingly working fine perhaps as Burst might have generated some very small or large number while MONO ended up with NAN or inf. The erroneous number didnt affect things as i think it was for thrust that controlled out of plane drift (ie. not in direction of turn or forward, but sideways), but because of error handling it would have turned thrust off and let to it drifting from target (otherwise it led to build crash or unrealistic accelerations).

If i have any similar behaviour and gain any more insight i'll let you know!

tim_jones likes this.