Jump to content


Photo

RTS Ground Pathfinding


  • Please log in to reply
5 replies to this topic

#1 wargeneral

wargeneral

    GMC Member

  • GMC Member
  • 35 posts

Posted 08 October 2011 - 09:07 AM

Ok, after looking at this for arround 5 hours, looking at numerous examples and rage quitting repeatedly i have finally decided to post a topic here to help with my task

what i am trying to do is get my RTS game, to have basic path finding, mp_path commands, it has a space and ground mode, since space didnt need pathfinding that was great, but now im working on the ground aspects of my RTS, here is what i have got, this is the enemy attack, in a alarm event in the main controller object, it is used with object enemy.


if enemyattack = 1
{ if (!instance_exists (obj_unit)) 
enemy = 0 else {
enemy = instance_nearest(x ,y,obj_unit ); if point_distance(x ,y,enemy .x,enemy .y) > 1100 {
enemyGoalX = enemy.x +lengthdir_x( 1000,enemydefend);


enemyGoalY = enemy.y +lengthdir_y( 1000,enemydefend);

target_dir = point_direction(x , y, enemyGoalX, enemyGoalY); if speed < enemySpeed speed += 0.5;
} else {
target_dir=point_direction (x, y, enemy.x, enemy.y); 


speed *= 0.95; }



now i need to add mp_path commands to it, but i am truely stumped on how to, i have had mixed results including jumping ships, and looking like they were on bungee cords, of all things,

please any help will be GREATLY appreciated :)
  • 0

#2 wargeneral

wargeneral

    GMC Member

  • GMC Member
  • 35 posts

Posted 08 October 2011 - 01:27 PM

any one............?
  • 0

#3 wargeneral

wargeneral

    GMC Member

  • GMC Member
  • 35 posts

Posted 10 October 2011 - 06:53 AM

still nothing come on guys............
  • 0

#4 Chazzmundo

Chazzmundo

    GMC Member

  • New Member
  • 275 posts
  • Version:GM8

Posted 10 October 2011 - 10:07 AM

Try putting this in Novice (ask a moderator to move it for you). With this type of problem you will likely get replies much faster.
  • 0

#5 filulilus

filulilus

    GMC Member

  • GMC Member
  • 928 posts
  • Version:GM:Studio

Posted 13 October 2011 - 09:08 AM

Read this, veeeery usefull and intreresting!
  • 0

#6 loverock125

loverock125

    GMC Member

  • GMC Member
  • 1596 posts
  • Version:GM8

Posted 13 October 2011 - 03:41 PM

Ok, after looking at this for arround 5 hours, looking at numerous examples and rage quitting repeatedly i have finally decided to post a topic here to help with my task

what i am trying to do is get my RTS game, to have basic path finding, mp_path commands, it has a space and ground mode, since space didnt need pathfinding that was great, but now im working on the ground aspects of my RTS, here is what i have got, this is the enemy attack, in a alarm event in the main controller object, it is used with object enemy.


if enemyattack = 1
{ if (!instance_exists (obj_unit)) 
enemy = 0 else {
enemy = instance_nearest(x ,y,obj_unit ); if point_distance(x ,y,enemy .x,enemy .y) > 1100 {
enemyGoalX = enemy.x +lengthdir_x( 1000,enemydefend);


enemyGoalY = enemy.y +lengthdir_y( 1000,enemydefend);

target_dir = point_direction(x , y, enemyGoalX, enemyGoalY); if speed < enemySpeed speed += 0.5;
} else {
target_dir=point_direction (x, y, enemy.x, enemy.y); 


speed *= 0.95; }



now i need to add mp_path commands to it, but i am truely stumped on how to, i have had mixed results including jumping ships, and looking like they were on bungee cords, of all things,

please any help will be GREATLY appreciated :)





mp_potential_step(x,y,stepsize,checkall) Like the previous function, this function lets the instance take a step towards a particular position. But in this case it tries to avoid obstacles. When the instance would run into a solid instance (or any instance when checkall is true) it will change the direction of motion to try to avoid the instance and move around it. The approach is not guaranteed to work but in most easy cases it will effectively move the instance towards the goal. The function returns whether or not the goal was reached.



In your case:

mp_potential_step(enemyGoalX,enemyGoalY,speed,false)

Edited by loverock125, 13 October 2011 - 03:42 PM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users