PDA

View Full Version : rpg ai hit-tests



mordormaster
April 10th, 2008, 05:56 PM
hiyar
i have been working on a pretty big rpg and have realised my ai is flawed, when it comes into contact with the object, called map, there the walls, i want it to bounce off the walls instead of walking throught them, so i divided it up into quarters and so when it hittests that quarter is bounces it away the correct way, but it aint working for me, can anyone have a look at it for me
thank you in advance :)

mordormaster
April 17th, 2008, 03:10 PM
can anybody help me ?

therobot
April 17th, 2008, 07:20 PM
hiyar
i have been working on a pretty big rpg and have realised my ai is flawed, when it comes into contact with the object, called map, there the walls, i want it to bounce off the walls instead of walking throught them, so i divided it up into quarters and so when it hittests that quarter is bounces it away the correct way, but it aint working for me, can anyone have a look at it for me
thank you in advance :)


You should really just go tile based and get a better grasp of what you're doing.

mordormaster
April 18th, 2008, 12:12 PM
i have treid that but i found art based easier

ArmoredSandwich
April 19th, 2008, 07:12 AM
I think you maybe want to consider an easier project if you can't answer these kind of questions.

Anyways:

if (_root.mc.hitTest(_root.map.wall1))
{
* check what key is pressed and move it the other direction.
}


Is this something you are looking for?

mordormaster
April 27th, 2008, 06:29 AM
it isnt for my main character
its for my enemy ai, i need it when the ai comes into contact with the walls it bounces off, because so far they walk straight through it

lancerawks
April 30th, 2008, 06:47 PM
onClipEvent(load){
speed = 5
}
onClipEvent(enterFrame){
this._x = speed
if(_root.map.hitTest(_x, _y, true)){speed = speed*-1}
}


Thats what I would do, have fun man :D