Project

General

Profile

Bug #3749

Yagrum Bagarn moves to different position on encountering

Added by Dan Sagunov 7 months ago. Updated about 1 month ago.

Status:
Closed
Priority:
Normal
Category:
AI
Target version:
Start date:
02/15/2017
% Done:

100%

Reproducibility:
Always
Operating system:
Other
Severity:
Normal

Description

I've captured Yagrum Bagarn strange behaviour starting from entering his location, it should say for itself:

https://dl.dropboxusercontent.com/u/17502574/sc.mp4 (sorry, the file is too heavy to upload here)

As you may see, Uupse Fyr is twitching as well as Yagrum himself.

Sometimes he remains static after passing his long way, sometimes not (screencast shows the last case).

bug3.omwsave - savegame file to reproduce (9.36 MB) Dan Sagunov, 02/15/2017 08:15 PM

bisect.log View (1.62 KB) Dan Sagunov, 02/16/2017 03:58 PM

Screenshot from 2017-08-12 15-57-22.png View - Yagrum floating (1.38 MB) Dan Sagunov, 08/12/2017 01:59 PM

Screenshot_20170812_201608.png View - OpenMW (2.85 MB) Andrei Kortunov, 08/12/2017 06:17 PM

Screenshot_20170812_202223.png View - Morrowind (1.08 MB) Andrei Kortunov, 08/12/2017 06:23 PM

History

#1 Updated by Dan Sagunov 7 months ago

UPD: I use openmw from PPA repos.

#2 Updated by scrawl . 7 months ago

Bisect would be very helpful.

#3 Updated by R. D. 7 months ago

As far as Uupse Fyr, she has a Follow package on Yagrum Bagarn so she is just turning to face him as he moves around.

#4 Updated by Dan Sagunov 7 months ago

Jannik Heller wrote:

Bisect would be very helpful.

Played with Bisect for a few hours. It says that the 05e4542 commit is the thing:

https://github.com/OpenMW/openmw/commit/05e4542

By the way, is anyone able to reproduce it? I am experiencing it even with a fresh character coc'ing into Corprusarium Bowels.

#5 Updated by scrawl . 7 months ago

Ok, I see what is happening. Yagrum is set to follow the NPC next to him. During his idle animation, he first moves to the right and once he's done so, the follow package kicks in turning him back towards the NPC, interrupts the idle animation which will then start over, moving more to the right, and so on.

As for that commit, I guess that just slightly changed the threshold for turning towards the target.

#6 Updated by scrawl . 7 months ago

  • Status changed from New to Confirmed

#7 Updated by Dan Sagunov 7 months ago

Checked everything again.

Revision aa441f2 is fine, next revision 05e4542 is not. Makes me says "Phew!" I did not mess with bisect, because building process takes meaningful time.

To reproduce the bug, I just do `sudo make install` and then run `openmw` from global scope.

I'm not familiar with openmw structure, but if you launch openmw binary of revision aa441f2 from local scope (in make environment) but having installed openmw of revision 05e4542, you'll experience the issue. Vice versa, if you launch 05e4542 binary with aa441f2 openmw installed on the system, you won't experience it.

#8 Updated by scrawl . 7 months ago

  • Category changed from 8 to AI

#9 Updated by Andrei Kortunov 2 months ago

Just tested an original game: follower turns to leader only when angle between follower and leader > 90 degrees.

In OpenMW follower turns to leader with much smaller angles.

#10 Updated by Dan Sagunov 2 months ago

Dan Sagunov wrote:

https://dl.dropboxusercontent.com/u/17502574/sc.mp4 (sorry, the file is too heavy to upload here)

Sorry, the link became unavailable. Here's the new one: https://www.dropbox.com/s/wnpcqi9291jxc47/sc.mp4?dl=0

#11 Updated by Andrei Kortunov 2 months ago

Turning to target is implemented here: https://github.com/OpenMW/openmw/blob/openmw-42/apps/openmw/mwmechanics/aipackage.cpp#L144

We can add a threshold here.

#12 Updated by Andrei Kortunov about 2 months ago

I tried to add a threshold here:

    if (isDestReached || mPathFinder.checkPathCompleted(pos.pos[0], pos.pos[1])) // if path is finished
    {
        osg::Vec3f actorDir = (actor.getRefData().getBaseNode()->getAttitude() * osg::Vec3f(0,1,0));

        float angle = std::acos(actorDir * (PathFinder::MakeOsgVec3(dest) - pos.asVec3()) / (actorDir.length() * (PathFinder::MakeOsgVec3(dest) - pos.asVec3()).length()));

        // Allow 90 degrees angle between actor and end point
        if (angle < osg::PI / 2)
            return true;

        // turn to destination point
        zTurn(actor, getZAngleToPoint(start, dest));
        smoothTurn(actor, getXAngleToPoint(start, dest), 0);
        return true;
    }

This check itself works, but AiFollow::execute is called very frequently (in every frame, I suppose), so a follower has no enough time to turn for large angles. Any ideas?

#13 Updated by Dan Sagunov about 1 month ago

Andrei Kortunov wrote:

I tried to add a threshold here:

[...]

This check itself works, but AiFollow::execute is called very frequently (in every frame, I suppose), so a follower has no enough time to turn for large angles. Any ideas?

Actually, with this fix Yagrum Bagarn's twitching won't stop, but will slightly change (he twitches, then stops twitching, then twitches again and so on). Uupse Fyr, at the other hand, stopped turning anywhere completely - is that because of frequent calling you mentioned?

#14 Updated by Andrei Kortunov about 1 month ago

of frequent calling you mentioned?

Yes. A follower has no enough time to turn to player.

#15 Updated by Andrei Kortunov about 1 month ago

An another question: do we need to recalculate path to leader in every frame?
Maybe if distance to leader < followDistance we can just turn follower to leader (if angle between leader and follower > 90 degrees).

#16 Updated by Dan Sagunov about 1 month ago

Andrei Kortunov wrote:

of frequent calling you mentioned?

Yes. A follower has no enough time to turn to player.

I'm not sure in that and I suggest you checking your formulas. I've done some logging, and I found that Uupse Fyr's angle (as found with your formulas) to Yagrum Bagarn is about 0.4 radians initially, so "pathTo" exits with "return true" for her without calling any turning functions.

I'm not really familiar with GameDev geometry, but I'm trying to check your formulas too.

#17 Updated by Andrei Kortunov about 1 month ago

FYI: I took angle calculation formula from MechanicsManager::awarenessCheck(). Maybe I am doing something wrong...

#18 Updated by Dan Sagunov about 1 month ago

Andrei Kortunov wrote:

FYI: I took angle calculation formula from MechanicsManager::awarenessCheck(). Maybe I am doing something wrong...

Thanks for information, so I found what was wrong on my side, sorry about blaming formulas. Now I see what is the problem with turning to large angles :) Maybe we can add a boolean in "AiFollowStorage" to perform full turning exactly to a target as a phase of package?

By the way, Yagrum Bagarn's idle animation makes him changing his z-position because of collisions with nearest objects, even without turning.

#19 Updated by Andrei Kortunov about 1 month ago

Maybe we can add a boolean in "AiFollowStorage" to perform full turning

Actually, this is how greeting is implemented in AiWander. When greeting we also need to turn NPC to player.
I suggest to take AiWander as example.

#20 Updated by Andrei Kortunov about 1 month ago

Yagrum Bagarn's idle animation makes him changing his z-position

Yes, and AiFollow tries to turn him to Uupse, and Uupse to him. If do not turn them, there is no twitching.

#21 Updated by Dan Sagunov about 1 month ago

Andrei Kortunov wrote:

Yagrum Bagarn's idle animation makes him changing his z-position

Yes, and AiFollow tries to turn him to Uupse, and Uupse to him. If do not turn them, there is no twitching.

Maybe there's no twitching, but there is floating in the air. I've just placed "return true" in the beginning of the if body and launched game with 'openmw --skip-menu --start "Corprusarium Bowels"'. What can I possibly do wrong?

#22 Updated by Andrei Kortunov about 1 month ago

What can I possibly do wrong?

You are doing nothing wrong.
"Floating in air" is due to collision box on Yagrum Bagarn (you can encounter this bug with other creatures too).
It is actually unclear how actors collision works in Morrowind. Take a loot at attached screenshots and bugs #1901 and #3803.

There are actually two separate bugs in your savegame:
1) Twitching due to buggy AiFollow
2) Floating in air due to creature collision box

#23 Updated by Andrei Kortunov about 1 month ago

  • Status changed from Confirmed to Resolved
  • Assignee set to Andrei Kortunov
  • Target version set to openmw-0.43
  • % Done changed from 0 to 100

#24 Updated by Alexei Dobrohotov about 1 month ago

  • Status changed from Resolved to Closed
  • Operating system changed from Linux to Other

Also available in: Atom PDF