Fix moving NPC vehicle pitch not synced - #1249
Conversation
|
@AmyrAhmady maybe its time?) |
AmyrAhmady
left a comment
There was a problem hiding this comment.
Some comments and some empty line breaks are removed for some reason
|
instead of doing things raw, can you use and put it in |
|
@AmyrAhmady thanks, that's much cleaner . |
AmyrAhmady
left a comment
There was a problem hiding this comment.
Please make sure you test it again in game after you made new changes, this would be my final change request and if you confirm it works in your test cases, I'll accept it
| { | ||
| front = (pos - position) / distance; | ||
| auto rotation = getRotation().ToEuler(); | ||
| rotation.x = 0.0f; // Discard the pitch a previous drive move may have baked in, it would skew the facing angle |
There was a problem hiding this comment.
I know this doesn't really change much, but since this line is meant to be for vehicles/driving only, let's move it in the if code block down there you made for moveType_ == NPCMoveType_Drive.
But remember it should be rotation_.x when you do.
There was a problem hiding this comment.
GTAQuat only has a glm::quat q member, so rotation_.x won't compile. also, rotation_.q.x is a quaternion component, not an euler angle.
but I think this line actually belongs in the non-drive path rather than the drive one. inside the drive block, the quaternion gets overwritten completely by the angleAxis composition, so a stale pitch there shouldn't really matter.
the case that actually needs it is when an NPC drives uphill and then gets told to walk. move() calls removeFromVehicle() itself, and sendFootSync() writes the full quaternion, so the ped keeps walking around tilted by 26.5° even on flat ground.
moving it into the if would also mean adding a matching else, which basically just means having the same line in both branches.
rotation sent in driver sync previously only used yaw, so moving npc vehicles looked flat instead of tilting toward their direction of travel.
now pitch is calculated from position vs target position while moving_, then combined with yaw before sync.