Problem with AIPlayer in Demo.
by game4Rest · in Torque Game Engine · 08/30/2005 (6:32 pm) · 5 replies
Hi,
When I changed the speed of my Avatar in the torque fps demo, something strange happened.
From server/scripts/player.cs,
I changed the maxForwardSpeed from 14 to 30.
And then the AIPlayer which is supposed to run around the town was stuck in the wall, sometimes
in the tree and didn't move.
With the speed 20, he wasn't stuck in, even though his movement seemed different from what
it used to be. But with 25 or higher, he couldn't move.
When I opened up the aiPlayer.cs, I found it doesn't contain datablock. Is it related to Player?
Is that the reason of my problem? If then, how can I solve this problem?
Thank you in advance.
Jin
When I changed the speed of my Avatar in the torque fps demo, something strange happened.
From server/scripts/player.cs,
I changed the maxForwardSpeed from 14 to 30.
And then the AIPlayer which is supposed to run around the town was stuck in the wall, sometimes
in the tree and didn't move.
With the speed 20, he wasn't stuck in, even though his movement seemed different from what
it used to be. But with 25 or higher, he couldn't move.
When I opened up the aiPlayer.cs, I found it doesn't contain datablock. Is it related to Player?
Is that the reason of my problem? If then, how can I solve this problem?
Thank you in advance.
Jin
About the author
Recent Threads
#2
At this moment, I'm gonna move the obstacles. Later when I have enough knowledge, I will try the others.
Jin
08/30/2005 (10:25 pm)
Thanks Brian *^^*At this moment, I'm gonna move the obstacles. Later when I have enough knowledge, I will try the others.
Jin
#3
If they hit something, come to a stop, then can't back out again, they're "stuck". There's an "onStuck" callback you can use to handle situations like this one. What exactly you DO in that callback is something else all together.
I'd recommend taking the bot back to its position last tick (which may mean saving that position every tick) and shifting it sideways a bit. "Which way is sideways?" That's where the "cross product" of two vectors comes in.
Vector 1: straight up: (0, 0, 1)
Vector 2: direction of travel.
The cross product of those two vectors will point perpendicular to its current path. I'm not sure how to GET a cross product in script, but I'm sure its possible. You might also want to move your bots up or down depending on the height of the terrain at their new position.
You could get Pretty Dang Fancy here, checking which "sideways" to go depending on the angle ("dot product) your bot strikes the surface it's running into. Or you could cast rays at a bit of an angle off to either side of its current direction, to see where it has more room.
There's also a resource that was posted recently about using a precompiled navigation map for AIs to help them navigate around a level.
08/31/2005 (11:00 am)
It sounds like the bots are getting stuck part-way inside the obstacles they're hitting.If they hit something, come to a stop, then can't back out again, they're "stuck". There's an "onStuck" callback you can use to handle situations like this one. What exactly you DO in that callback is something else all together.
I'd recommend taking the bot back to its position last tick (which may mean saving that position every tick) and shifting it sideways a bit. "Which way is sideways?" That's where the "cross product" of two vectors comes in.
Vector 1: straight up: (0, 0, 1)
Vector 2: direction of travel.
The cross product of those two vectors will point perpendicular to its current path. I'm not sure how to GET a cross product in script, but I'm sure its possible. You might also want to move your bots up or down depending on the height of the terrain at their new position.
You could get Pretty Dang Fancy here, checking which "sideways" to go depending on the angle ("dot product) your bot strikes the surface it's running into. Or you could cast rays at a bit of an angle off to either side of its current direction, to see where it has more room.
There's also a resource that was posted recently about using a precompiled navigation map for AIs to help them navigate around a level.
#4
I deeply appreciate your kind comments.
Even though I can understand what you're talking about, as I began to study
torque engine lately, I will have to spend more time to put them in game.
So, let me come back again with this when I make some progress.
Thank you again.
Jin
08/31/2005 (3:56 pm)
Dear Mark,I deeply appreciate your kind comments.
Even though I can understand what you're talking about, as I began to study
torque engine lately, I will have to spend more time to put them in game.
So, let me come back again with this when I make some progress.
Thank you again.
Jin
#5
2) The bot will run straight to the pointer. A problem with making the bot run faster is that when he turns to the next marker he "skids", and sort of gets a new angle to run to the next marker. Then trees and other stuff can get in the way.
09/04/2005 (11:47 pm)
1) If you look at the path in the editor you see a smoothed line. Remember that this is not how the bot is going to run though. 2) The bot will run straight to the pointer. A problem with making the bot run faster is that when he turns to the next marker he "skids", and sort of gets a new angle to run to the next marker. Then trees and other stuff can get in the way.
Torque Owner Brian "Bazz" Staudinger
Is that the reason of my problem? No I dont think so, its just that it has more momentum so slides off the path abit leaving a building between it and its next path node.
If then, how can I solve this problem? Move the building and tree out of the way:) well thats the ezy way, or make a new path, or add some jam detection to the AIscripts, or.....