Entity Turning Question
Blitz3D Forums/Blitz3D Beginners Area/Entity Turning Question
| ||
I have entities that are moving forward. Their entityY() is always set to 2. When they collide with another entity they are programmed to turn away to a random angle (-180 to 180) using the TurnEntity command: TurnEntity Entity, 0, random angle, 0 The problem is that at times, the Y position of the entities changes slightly. It might be 1.9755, 2.2012 etc... I have not monitored it but I believe that pitch, yaw and roll may be slightly changed too. Is there something I am overlooking about turning entities or something I should do to compensate for this? |
| ||
You could just force your y pos each frame |
| ||
Have you tried using this function?Function Turn_Entity(entity,x,y,z,global=false) RotateEntity EntityPitch(entity,global)+x,EntityYaw(entity,global)+y, EntityRoll(entity,global)+z,global End Function Use it exactly like turnentity, but it will give better results for what you need. Turn_Entity(mesh,1,0,0) |
| ||
Thanks for your answers boomboom - I have compensated (so far) by doing exactly that. Ross C - Thanks - I did try a straight RotateEntity but not in a function like that. I will give it a try. I edited the function slightly. It seems to work fine. I will test it extensively later. Function Turn_Entity(entity, x#, y#, z#, coordsys=False) RotateEntity Entity, EntityPitch(entity,coordsys)+x, EntityYaw(entity,coordsys)+y, EntityRoll(entity,coordsys)+z, coordsys End Function I take it that TurnEntity has a bit of a problem with precision. |
| ||
Its not that. Turn Entity applies the rotations you specify, but based on what rotation the entity is currently at. That might not be 100% accurate, but it's different from the way RotateEntity works. I've never personally found any use for the TurnEntity command. |
| ||
TurnEntity has no problem with precision. |
| ||
A single TurnEntity is just as precise as RotateEntity. Both are not exact but the error is small. The problem is that small errors accumulate. After doing TurnEntity thousands of times the total error becomes noticable. |
| ||
what floyd is talking about is the butterfly effect and floating point variable imprecision. |