Some AIPlayer path issues
by Bullitt Sesariza · in Torque Game Engine · 02/26/2008 (7:37 pm) · 13 replies
Hi, I've made approx. 20++ AIPlayers in my game. Also, I used a static camera from the advanced camera resource so almost all of my AIPlayers are visible. There are a few issues that currently happen.
1. Occasionally the animation looks rather weird. It looks jittery. Eg. the animation starts from the starting frame and up to half or even a fourth of the animation's length, it reverts back to the start of the animation. So it looks like the animation is trying to play and succeed but cannot finish the whole animation frame and thus reverts back to the start of the animation (I made it to always play the thread). It makes the game look weird. How do I fix this?
2. My AI's paths are rectangular in shape. And I don't know why, but in one of its markers, it always turns 270 degrees whereas all the other are 90. Why is this happening? How do I fix this? BTW, here are the path and markers in question. The faulty one is the "Lane2_Start" marker.
3. Well, the third issue is actually an old issue that I decided to skip. It seems like the AIPlayers movement & position are warped / interpolated if the game is lagging or have a low FPS (well, currently my game only has avg. 16 FPS). But what I don't get is why are there some objects that are warped and some aren't? FYI, in 1 path, there is a possibility that it would consist of many AIPlayers. So I am afraid if, eg. in one path an AIPlayer is warped but the other aren't, the distance between one and another will be different and they would collide. How do I make the all the object warp if needed and not just one or two? I need it to conserve the distance between AIPlayers to always be equal.
Thanks a lot in advance.
1. Occasionally the animation looks rather weird. It looks jittery. Eg. the animation starts from the starting frame and up to half or even a fourth of the animation's length, it reverts back to the start of the animation. So it looks like the animation is trying to play and succeed but cannot finish the whole animation frame and thus reverts back to the start of the animation (I made it to always play the thread). It makes the game look weird. How do I fix this?
2. My AI's paths are rectangular in shape. And I don't know why, but in one of its markers, it always turns 270 degrees whereas all the other are 90. Why is this happening? How do I fix this? BTW, here are the path and markers in question. The faulty one is the "Lane2_Start" marker.
new Path(PathLane1) {
canSaveDynamicFields = "1";
isLooping = "1";
new Marker(Lane1_Start) {
canSaveDynamicFields = "1";
position = "8.2 -460 1";
rotation = "1 0 0 0";
scale = "1 1 1";
seqNum = "1";
type = "Normal";
msToNext = "1000";
smoothingType = "Spline";
};
new Marker(Lane1_End) {
canSaveDynamicFields = "1";
position = "8.2 -390 1";
rotation = "1 0 0 0";
scale = "1 1 1";
seqNum = "2";
type = "Normal";
msToNext = "1000";
smoothingType = "Spline";
};
new Marker(Lane2_Start) {
canSaveDynamicFields = "1";
position = "-1.8 -390 1";
rotation = "1 0 0 0";
scale = "1 1 1";
seqNum = "2";
type = "Normal";
msToNext = "1000";
smoothingType = "Spline";
};
new Marker(Lane2_End) {
canSaveDynamicFields = "1";
position = "-1.8 -460 1";
rotation = "1 0 0 0";
scale = "1 1 1";
seqNum = "1";
type = "Normal";
msToNext = "1000";
smoothingType = "Spline";
};
};3. Well, the third issue is actually an old issue that I decided to skip. It seems like the AIPlayers movement & position are warped / interpolated if the game is lagging or have a low FPS (well, currently my game only has avg. 16 FPS). But what I don't get is why are there some objects that are warped and some aren't? FYI, in 1 path, there is a possibility that it would consist of many AIPlayers. So I am afraid if, eg. in one path an AIPlayer is warped but the other aren't, the distance between one and another will be different and they would collide. How do I make the all the object warp if needed and not just one or two? I need it to conserve the distance between AIPlayers to always be equal.
Thanks a lot in advance.
#2
For number two, if the AI reaches the third marker (the "Lane2_Start"), it is yaw-ed 270 degree. But when it reaches all the other 3 markers, it's yaw-ed -90 degree (not 90 degree like my original post, my bad. :P). Obviously, the right one should be the -90 degree yaw because it is the shortest yaw. But only in that particular marker does the AI yaw 270 degree.
EDIT:
BTW, forgot to say thanks.
02/26/2008 (11:12 pm)
@LeeFor number two, if the AI reaches the third marker (the "Lane2_Start"), it is yaw-ed 270 degree. But when it reaches all the other 3 markers, it's yaw-ed -90 degree (not 90 degree like my original post, my bad. :P). Obviously, the right one should be the -90 degree yaw because it is the shortest yaw. But only in that particular marker does the AI yaw 270 degree.
EDIT:
BTW, forgot to say thanks.
#3
02/27/2008 (12:17 am)
Is this a plane?
#4
02/27/2008 (6:17 pm)
No, an AIPlayer. Similar to Kork in the starter.fps.
#5
Sorry if I'm being dense, but I really don't comprehend the problem.
02/27/2008 (6:30 pm)
So...he turns left instead of right, is what you're saying? Or vice versa?Sorry if I'm being dense, but I really don't comprehend the problem.
#6
02/27/2008 (7:16 pm)
No, he turns 270 degree to the right instead of 90 degree to the left. But only at that particular marker. In all the other 3 markers, he turns 90 degree to the left (which is the correct one).
#7
Or he just rotates 270 before going to the correct marker, like Odie the dog?
02/27/2008 (7:31 pm)
So...he doesn't go to the next marker after that? But wanders off into lala land?Or he just rotates 270 before going to the correct marker, like Odie the dog?
#8
What happens if you make the last turn a little acute or obtuse?
Kinda interesting...sorry I don't know the answer off the top of my head. I'm guessing the answer is most likely in the AIPlayer source.
02/27/2008 (7:48 pm)
I just realized it is almost surely the latter that you must be talking about. Kinda interesting, I checked out your coordinates all appear to be 90 degree turns all right. What happens if you make the last turn a little acute or obtuse?
Kinda interesting...sorry I don't know the answer off the top of my head. I'm guessing the answer is most likely in the AIPlayer source.
#9
3) use server positions not client positions. Server positions are always updated equally. It's only when stuff gets to the client that it might need to interpolate. if(isServerObject())
02/27/2008 (10:09 pm)
2) are the paths looping? Is he going from lane2_start to lane2_start and then moving on (hitting the same node twice)?3) use server positions not client positions. Server positions are always updated equally. It's only when stuff gets to the client that it might need to interpolate. if(isServerObject())
#10
Yup, that's about it.
@William
2. I think not. Although I use the modified AIPlayer.cs script for this, most of the codes are still the original ones. Including the onReachDestination, onEndOfPath, and onEndSequence. And based on that codes's logics, it won't act that way. Furthermore, I have only 4 markers in my path. So I don't understand why it would trigger the same marker twice. Maybe like Le has said, it's in the AIPlayer' source code.
3. You know, after I implemented the fix for the number 1 problem (the jerky animation), the third problem seems nonexistent. So maybe the first and third problem have the same cause.
02/28/2008 (5:37 pm)
@LeeYup, that's about it.
@William
2. I think not. Although I use the modified AIPlayer.cs script for this, most of the codes are still the original ones. Including the onReachDestination, onEndOfPath, and onEndSequence. And based on that codes's logics, it won't act that way. Furthermore, I have only 4 markers in my path. So I don't understand why it would trigger the same marker twice. Maybe like Le has said, it's in the AIPlayer' source code.
3. You know, after I implemented the fix for the number 1 problem (the jerky animation), the third problem seems nonexistent. So maybe the first and third problem have the same cause.
#11
02/28/2008 (5:54 pm)
You know, when I turn the AI's maxForwardSpeed down, it rotates -90 degree at all markers. I don't know what happened. Maybe it's just an optical illusion or maybe if it is faster, it passes the marker a little bit further so the yaw calculation is not the same. Either way, IMHO it can be considered done for now. It's not that crucial issue anyhow. Thanks a lot guys.
#12
This code is for drawing a quad directly in front of the object (in this case the AIPlayer). With this code on, I can see that it was not an optical illusion after all. The orientation's calculation from AIPlayer::getMove() is indeed the faulty one because it couldn't always resulted in the shortest yaw.
03/03/2008 (6:52 pm)
Latest update: I've added this code in shapeBase::renderObject() method://Quad in front of the object
glPushMatrix();
glColor3f(0, 0, 1);
glTranslatef(0,box.y+5,0); //Translate to the front of the object
glScalef(box.x,5,box.z); //scale to the quad's size
glBegin(GL_QUADS);
for(vert = 0; vert < 4; vert++) {
int idx = cubeFaces[faceIdx][vert];
glVertex3f(cubePoints[idx].x * 1 + 0, cubePoints[idx].y * 1 + 0, cubePoints[idx].z * 1 + 0);
}
glEnd();
glPopMatrix(); //End quadThis code is for drawing a quad directly in front of the object (in this case the AIPlayer). With this code on, I can see that it was not an optical illusion after all. The orientation's calculation from AIPlayer::getMove() is indeed the faulty one because it couldn't always resulted in the shortest yaw.
#13
*edit* I think my problem was related to the speed of the AI and the closeness of the markers to each other. It wasn't registering it had reached a marker before it had passed it, so occasionally would double back. I spread out the nodes and slowed down the AI speed and the problem is gone.
03/05/2008 (10:33 pm)
This is odd but I notice my bots doing a 270 degree turn on path corners too.... anyone know of a fix?*edit* I think my problem was related to the speed of the AI and the closeness of the markers to each other. It wasn't registering it had reached a marker before it had passed it, so occasionally would double back. I spread out the nodes and slowed down the AI speed and the problem is gone.
Torque Owner Lee Latham
Default Studio Name
For #2, I don't understand, please go into more detail.