Need help with AI

thepopeisgod

  • Posts: 13
Hey guys I am creating a top down rpg.  It's still in pre alpha.  You can play it here: http://thepopeisgod.com/

The current behavior is not currently implemented into the game, because I need some help. 

If you want to help I uploaded it to the forge under Line of sight wip

The way I am trying to get it to work:
I made a Dynamic region that follows the playable character.  When an enemy enters that region, the enemy will move toward the player and attack them. 

Issues:
I cannot for the live of me figure out how to get the enemy to actually move to the player character.

Things I have tried:
I tried
and a few other things but all the enemy does is move to the bottom right corner of the screen.

Attributes:

line of site:  the region that is created around the player
enemy actor (1-4) : the different enemy actors in the scene

gruffman

  • *
  • Posts: 564
have 2 game attributes, one for the main actors X and Y co-ordinates. Update them constantly in the "always" event.

might be better placing regions on each of the bad guys. then when the hero enters a bad guys region, the bad guy adjusts his X and Y eg

if good_guy_X > my X, set my X to my X +1
otherwise set my X to my X -1
if good_guy_Y < my Y, set my Y to my Y -1
otherwise set my Y to my Y +1

in your example, if that region is on the hero, you shouldnt be pushing the hero at all. you want to adjust the x and y of the villains not the hero. You are not too far off though, well done!
Now available for all Android Devices - Happy Face Concentration
My Games To Date
Find A Face / Hero Of Oda / Snakes And Ladders
Hungry Monkey available at fgl.com for Sponsorship
My site - Gruffgames.com

thepopeisgod

  • Posts: 13
Yeah That is how I started it out but moved the region to the player character after getting stuck. 

Also I did have it set to pushing the enemy but I was messing with other options and forgot to change it back for the picture. 

The issue I have though is with the fact that when I Use " x of region" it always points to the bottom right of the level regardless. 

I will try it your way and see if I get results thank you.   

thepopeisgod

  • Posts: 13
have 2 game attributes, one for the main actors X and Y co-ordinates. Update them constantly in the "always" event.

might be better placing regions on each of the bad guys. then when the hero enters a bad guys region, the bad guy adjusts his X and Y eg


Also the other issue I had when I was setting the region for the enemy was that It would only create one region for all the actors.  I will post a follow up when I code it up.

thepopeisgod

  • Posts: 13
Thank you for your help.  I got it to work with your suggestion here is what I did.  I still need to tweak it a bit to get the placement just right but here you go.