Skip to content
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

Merged
1 commit merged into from Aug 17, 2017
Merged

Conversation

akortunov
Copy link
Collaborator

Fixes bug #3749.

Note: in current implementation followers turn faster than in Morrowind. Is there any way to fix it?

{
osg::Vec3f dir = targetPosition - actorPosition;

float faceAngleRadians = std::atan2(dir.x(), dir.y());
Copy link

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)

Copy link
Collaborator Author

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?

Copy link
Collaborator Author

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).

@ghost
Copy link

ghost commented Aug 13, 2017

Note: in current implementation followers turn faster than in Morrowind. Is there any way to fix it?

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') ?

@akortunov
Copy link
Collaborator Author

I mean angular velocity.
Just run in circles around any follower in vanilla game and OpenMW.
Maybe I'm wrong, but looks like in OpenMW followers have higher angular velocity.

Don't we have a speed argument to zTurn?

I tried to use it, but without success. Even with very small values there is no noticeable difference.

@ghost
Copy link

ghost commented Aug 16, 2017

Don't we have a speed argument to zTurn?

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') ?"

@akortunov akortunov force-pushed the aifollow branch 2 times, most recently from 55870a4 to fceeed0 Compare August 17, 2017 18:41
@akortunov
Copy link
Collaborator Author

I rewrote this PR to use epsilonRadians.

Notes:

  1. I did not change pathTo() function because we need a threshold only in AiFollow.
  2. Looks like followers in Morrowind turn around without playing animation. I am not sure if we want to replicate this behaviour.

@ghost ghost merged commit b73ed5c into OpenMW:master Aug 17, 2017
@akortunov akortunov deleted the aifollow branch September 3, 2017 14:47
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant