September 23, 2019, 03:07:09 PM

Author Topic: Blitz3D bug with EntityPitch/Yaw/Roll() after using ALignToVector()  (Read 50 times)

Offline TomToad

  • Sr. Member
  • ****
  • Posts: 429
Blitz3D bug with EntityPitch/Yaw/Roll() after using ALignToVector()

There seems to be a bug after using AlignToVector() on an entity, EntityPitch/Yaw/Roll() commands sometimes give wrong values.  Now I do know that EntityPitch, etc.. will return different values than used in RotateEntity, but those values are equivalent to each other and still orientates the objects properly.  This is different.  Object orientation is wrong.

The example provided shows the error.  The left box is aligned to a random axis.  The right box is orientated to the position of the left by using ENtityPitch()... Most of the time, the boxes align just fine.  Every now and then, the right box is aligned wrong.  I am aligning to the y axis as that seems to produce the problem more often, but it happens on the x and z as well.

I figured out that AlignToVector does not align to an absolute orientation, but rather relative to the entity's previous orientation.  This is understandable as this will allow smooth alignment when using the rate parameter.  Apparently transforming from certain orientations to others causes EntityPitch etc... to mess up.  By orientating the entity to 0,0,0 prior to using AlignToVector seems to remove the problem.
8 rabbits equals 1 rabbyte.

Offline STEVIE G

  • Sr. Member
  • ****
  • Posts: 307
Re: Blitz3D bug with EntityPitch/Yaw/Roll() after using ALignToVector()
« Reply #1 on: September 17, 2019, 06:24:19 PM »
The test looks ok to me after watching it for a few minutes?

My understanding is that Aligntovector uses quarternions for rotation, as does turnentity, but rotateentity uses euler angles and each axis is performed in a specific order.   Maybe the dodgy result is where the pitch is exactly +- 90 so your getting some gymbal lock where the roll and yaw cannot be properly defined?

Sorry - just some thought - not much help!