DOTS - movement and rotation bug/feature?

I found this in the next section but think it would crop up here.
If the position of a cube / person is 0, 1, 0 and the move destination is 0,0,0 or vice versa then the object is disappearing and ending up at nan, nan, nan

If I comment out the rotation look at then it works ok.

Not currently sure how to add back in the rotation so it works in all cases…

{I hunted down your code in the repository on GitLab and it was doing the same as mine.}

[EDIT - I’d ended up with my prefab at 0,1,0 as I had scaled it to 2 and had wanted to raise it to match the other objects ]

I’m not even sure how you would get Vector3 variables to a NaN. There’s gotta be an achievement for that.

It’s a float3 and we have before, earlier in the course… so I’m not that clever or special…

I mean getting them to a NaN. In a tightly structured language, getting a float to be NaN isn’t something I thought was possible.

Not sure why you are so surprised and making a snide remark for a legitimate question from OP about getting a float to NaN. Perhaps if you had followed the lesson this was commented under (which causes a NaN you thought not possible) you would realize this is fairly common.

Anyway to answer OPs question, the reason we get a NaN is because we normalize a zero vector when the position of the object is already at the destination. Not sure if this is fixed in the next few lessons but just pointing out the reason why the object disappears.

Each to their own I suppose. Welcome to the site.

It’s actually not covered. Nathan was aware that the cubes would disappear, but had the cause wrong. It should be avoided by returning if the cube is at the destination, but it’s possible this corner case is slipping through the cracks.

float x = 1f/0f; //NaN

Privacy & Terms