Jump to content


Photo

Top down AI, need help developing it


  • Please log in to reply
3 replies to this topic

#1 CrazyGuyGames

CrazyGuyGames

    YYGF Member

  • GMC Member
  • 194 posts
  • Version:GM8.1

Posted 21 June 2012 - 11:39 PM

So I'm making a 2d game, and is a top down game also, but I'm having problems developing a pathfinding game, Im good developing Ai's for platformers not top down games.
This is the code Im using so far, is very simple, Im just using gm's fucntions, but are not what I want, heres the code:
a = check_nearest(obj_dummy);
if place_free(x+5,y) && place_free(x-5,y) && place_free(x,y+5) && place_free(x,y-5)
{move_towards_point(a.x,a.y,2.5)};
else
{mp_potential_step(a.x,a.y,0.5,1);}
Don't worry about the check_nearest script, it checks the nearest enemy (if you want this code pm me its very usefull), so if you can please help.
  • 0

#2 zehevi

zehevi

    GMC Member

  • GMC Member
  • 637 posts
  • Version:GM8

Posted 22 June 2012 - 01:28 AM

So you told us what you don't want, but what DO you want?
And what does your AI suppose to do? shoot from range? follow you everywhere?

Please provide more information as it is yet impossible to read your thoughts through the web.

Zehevi.
  • 0

#3 CrazyGuyGames

CrazyGuyGames

    YYGF Member

  • GMC Member
  • 194 posts
  • Version:GM8.1

Posted 22 June 2012 - 11:48 AM

Ok ok sorry, so the AI is supoused to follow a objetive, thats all, I could easly do that by move_towards_point()
but I want it to avoid solid objects, and game maker's move mp_potential_step(a.x,a.y,0.5,1) is not very elaborated, and when colides with a solid object, it starts to roll.
What I need help is on make my own "mp_potential_step(a.x,a.y,0.5,1)", I just don't have idea how to start the avoiding code, I found something that can be usefull, check_line_collision or something like that, but still I don't know how to start the script.
  • 0

#4 zehevi

zehevi

    GMC Member

  • GMC Member
  • 637 posts
  • Version:GM8

Posted 22 June 2012 - 12:45 PM

You can use mp_potential_settings and set the maxrot to something like 90, this way it won't rotate,
but for even a better solution I would use mp_potential_path or mp_grid_path instead.
Just don't forget to create a path before using those functions as it will return an error.

The idea is to plan your motion before you move, this way the object won't get stuck.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users