AIPlayer Spinning[Solved]

Expanding and utilizing the engine via C++.
22 posts Page 2 of 3
Posts: 418
Joined: Wed Feb 18, 2015 7:36 am
by marauder2k9 » Fri Dec 13, 2019 1:28 pm
hmmm if it is only happening on the initial spawn, is it possible the initial spawn is loading some fps controls on that initial character?

Are you loading the same datablock on the initial spawn as you are on the respawn? Sounds like the initial spawn is loading in a player controlled character and the respawn is loading in a purely ai character.

Check the initial spawns datablock in the editor and see if there are a few dynamic fields
Posts: 104
Joined: Sat Apr 11, 2015 9:08 pm
by Happenstance » Fri Dec 13, 2019 5:57 pm
My guess is that this is going to be an issue deeper in the engine, you were probably on the right track looking at the yaw code. The fact that it happens during the initial spawn makes me think it's an issue with the way yaw data is initially networked & interpolated.

Is there any change if you disable warping?
// Set these to 1 in aiPlayer.cpp
static S32 sMaxWarpTicks = 1;          // Max warp duration in ticks
static S32 sMaxPredictionTicks = 1;   // Number of ticks to predict
Posts: 130
Joined: Thu Apr 30, 2015 5:35 am
by TorqueFan » Fri Dec 13, 2019 8:53 pm
@ Duion : You are right to suggest this. I totally did try that as well yet the problem persisted.

@ marauder2k9 : It's a good idea, and something I hadn't thought to check, but looking over it all I've got the global variables...
$Game::defaultPlayerClass = "AIPlayer";
$Game::defaultPlayerDatablock = "AIPlayer";
...and spawning in using the same Sim::spawnObject() consolefunction:
%player = spawnObject($Game::defaultPlayerClass, $Game::defaultPlayerDatablock);
@ Happenstance : I found the static variables enherited from Player, so ended up changing those in player.cpp to 1. The visual effect of this is the spin occurs immediately and is much more noticeable. If someone's trying to replicate this that'll likely do the trick =). Setting these values to 1 I don't have to wait for the AIPlayer to be rotating while an early loading hitch occurs to produce the bug, the AIPlayer will display the unwanted behavior immediately. However, it does allow for a good look at it. With the warping disabled, it is easy to see that the issue isn't happening if the AIPlayer is walking on a straight forward vector but interpolates incorrectly as soon as a rotation occurs.

Speaking of looking at it, I will get a capture of this and post it up here as soon as I can so folks can see it.

Thanks for the help on this everyone, it's been a rough haul and since this particular bug has persisted since early in the game's development I figured it did warrant a bit of scrutiny.
Posts: 1603
Joined: Sun Feb 08, 2015 1:51 am
by Duion » Fri Dec 13, 2019 11:32 pm
This is probably a stupid solution, but at game launch you could kill them all and instantly respawn them.
Posts: 130
Joined: Thu Apr 30, 2015 5:35 am
by TorqueFan » Sat Dec 14, 2019 2:06 am
Naw, it's the closest thing I've currently got to a solution without attempting to repair some confusing interpolation code and netcode that inherits from another class. I feel like, "If it looks good it is good". I guess when you really boil it down to its essence, any game is just smoke and mirrors =)

Here I've got a colleague that 'might' have a handle on this, but if he doesn't I've just been planning to do something similar to what you are proposing. Perhaps the initial spawn in and then respawn might not trigger the load hitch though, so I'm brewing up a few other plans around that.

At the end of the day, I'd love to see this closet case hammered down for future users of the engine regardless. I couldn't grab a vid of it today, just too much other stuff going on, but should be able to get to it this weekend.
Posts: 104
Joined: Sat Apr 11, 2015 9:08 pm
by Happenstance » Sat Dec 14, 2019 3:20 am
Tinker with those warp settings as well - try setting them to 64 or even 128 and see how that changes things.

My suspicion is that the AIPlayer's yaw handling is breaking in situations where the client & server desync. The server says the AIPlayer's rotation is one thing and it should turn to this angle but the client thinks it's a slightly different angle. Once an update packet is received by the client the rotation is synced back to the server's version and the change in rotation is interpolated over several ticks. The difference in angles could potentially be enough to result in a wildly different return value in that bit of code that calculates the shortest turning distance (see comment in aiPlayer about "shortest way around a circle"). You'd see the AIPlayer spin from one extreme to the other as it corrects the rotation if the difference was large enough.

That's my shot in the dark theory, anyway.
Posts: 130
Joined: Thu Apr 30, 2015 5:35 am
by TorqueFan » Sat Dec 14, 2019 8:00 pm
@ Happenstance Yep, you are right

I think we have this solved. My colleague was able to discover my shortcoming around this issue. What happened here was when I implemented the resource by @ GuyA posted above, I hadn't implemented the adjusted warping code from the other resource by Ivan. I tried each resource separately, while Guy explicitly had said that Ivan's code would be necessary for his resource to work. I was wondering why I had used that resource numerous times in the past and it worked. This is why I could still get the turn rate working but the warp was still broken.

When I revisited this all earlier this morning, rather than create a new AIPlayer datablock as in the resource I added the maxTurnRate stuff to the player.h and player.cpp code as suggested in the comments of Guy's resource. Basically adding only the relevant warp change to AIPlayer in getAIMove(). So far, this all equates to a fix here for me. I hadn't been able to replicate the issue since.

To Note
Stock Torque presently does suffer from this closet case. Without modification of the warp code and that limit on turn rate, these issues can still crop up. I noticed that some of the existing code does include similar changes to what Ivan had originally proposed. However, if it isn't used in conjunction with Guy's maxTurnRate limiting warping can be broken in certain cases.
Posts: 130
Joined: Thu Apr 30, 2015 5:35 am
by TorqueFan » Sat Dec 14, 2019 10:44 pm
Damn, it popped up again. I believe existing AIPlayer rotation warping is not providing the level of functionality that it should.
Posts: 130
Joined: Thu Apr 30, 2015 5:35 am
by TorqueFan » Tue Dec 24, 2019 7:33 pm
I fixed this, but it wasn't pretty...

I ended up having to completely replace the AIPlayer class with an older version from around 2015/2016. There have been several pose, navigation, and AFX-animation additions since that time. Something broke the rotation warping, unfortunately, so I was forced to revert.
Posts: 495
Joined: Tue Feb 03, 2015 9:50 pm
by Azaezel » Wed Dec 25, 2019 7:13 pm
No guarantees, since I haven't been hitting that specific issue, but a couple things of note: ... .cpp#L6371
+ ... .cpp#L6477 really should probly read signed there. beating that one up a bit before a PR to fix it.
and if it is indeed a wrap issue, did add a pair of ... #L240-L251 you can give a shot, see if that helps.
22 posts Page 2 of 3

Who is online

Users browsing this forum: Bing [Bot] and 3 guests