New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AiFollow: add a threshold when turning to target #1391
Conversation
apps/openmw/mwmechanics/aifollow.cpp
Outdated
{ | ||
osg::Vec3f dir = targetPosition - actorPosition; | ||
|
||
float faceAngleRadians = std::atan2(dir.x(), dir.y()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will get NaN here if direction is zero (actor and target in the same position)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I got It.
But we have the same code in AiWander, AiFace and pathfinding.cpp (I just took already existing formula).
Should we change these files too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, IIRC, std::atan2(0, 0) == 0 (atan2 should return NaN only if dir.x() is NaN or dir.y() is NaN).
Don't we have a speed argument to zTurn? Or do you mean there is a delay before they start turning at all? Is there any reason we can't use the threshold function built in to zTurn ('epsilonRadians') ? |
I mean angular velocity.
I tried to use it, but without success. Even with very small values there is no noticeable difference. |
Then we should probably find out what's wrong with it, rather than adding a new method on top. What about this one? "Is there any reason we can't use the threshold function built in to zTurn ('epsilonRadians') ?" |
55870a4
to
fceeed0
Compare
I rewrote this PR to use epsilonRadians. Notes:
|
Fixes bug #3749.
Note: in current implementation followers turn faster than in Morrowind. Is there any way to fix it?