Stencyl 3.4.0 is now out. Get it now!

How would I make the Follow Target behavior always follow a specific actor?

BootleBen

  • Posts: 3
I'm trying to make a top-down shooter, and I've figured out how to make the enemies face the player. But, I have to double click on the enemy and select the actor for every enemy. I'm also trying to spawn enemies, but they won't follow the player. I'm very new to Stencyl, so I don't really know how I would do it myself. Is there anyway to modify the behavior to always follow an actor?

Shayaan

  • Posts: 22
I'm stuck here too in my top-down shooter.

I need the enemy to follow my player dodging anything that comes in between and finding out a way for itself around the map.

Hope someone helps.

VoidShard

  • Posts: 80
When the player is created:
Set game attribute with name player to self.

Enemies:
Point toward (value of game attribute with name player)


Shayaan, you might want to look at A* pathfinding. It can take a lot of calculations but it's worth trying.

BootleBen

  • Posts: 3
Uh, sorry, but could you elaborate a bit on that? I'm very new at this stuff... thanks.

VoidShard

  • Posts: 80
Use these blocks. I'm not sure what code you're using to find the position of the player (probably using atan2) but this is how you get the position of the player.

merrak

  • *
  • Posts: 1309
Getting the enemy to navigate around obstacles will require some kind of pathfinding implementation--A* being a common one. I have an extension you can use for this purpose (http://community.stencyl.com/index.php/topic,45313.0.html)

Detecting obstacles between the enemy and its target will necessitate raycasting. There was an extension for this, but it's old. I think this is it: http://community.stencyl.com/index.php?topic=16734.0

Neither of these are simple to implement. Since you said you're new to this stuff, there'll be a lot to read and experiment with. I'd suggest implementing other parts of your game first as a way to gain more experience with Stencyl.

Shayaan

  • Posts: 22
 ;D Hey I just downloaded this extension but I have no clue how to use this.  :-\

I want the AI to just move around dodging obstacles but when I'm in range, I want it to shoot at me.

Just wanted to ask if there's a simpler way to do this?

VoidShard

  • Posts: 80
Getting line of sight isn't actually too difficult if you use the excessively wasteful physics engine style:
attached.