Discussion:
Chase the hero
ER
2016-09-12 17:06:01 UTC
Permalink
Hi,

How do I get the enemies "chase" after the hero ?

Right now I have one enemy on screen and moves until it hits a wall or
whatever
then randomly chooses a new direction to go. Which is ok but dull,
and robotic if you will.

I would like the enemies to chase after the hero but don't know how to
do that.

Enemy(1) is the array with current enemy.


Thanks.



_______________________________________________
Unsubscribe by sending a message to:
<nug-***@lists.xojo.com>

List Help: <***@xojo.com>
Jon Ogden
2016-09-12 17:26:08 UTC
Permalink
You know the coordinates of the hero right?

So calculate a vector between the enemy and the hero. Have the enemy move along that vector.
Post by ER
Hi,
How do I get the enemies "chase" after the hero ?
Right now I have one enemy on screen and moves until it hits a wall or whatever
then randomly chooses a new direction to go. Which is ok but dull, and robotic if you will.
I would like the enemies to chase after the hero but don't know how to do that.
Enemy(1) is the array with current enemy.
Thanks.
_______________________________________________
_______________________________________________
Unsubscribe by sending a message to:
<nug-***@lists.xojo.com>

List Help: <***@xojo.com>
Tim Jones
2016-09-12 19:14:01 UTC
Permalink
Path determination and assignment is one of the more frustrating elements in game mechanics. Especially if you have a lot of obstacles on the map that the characters must take into consideration.

Apple has a relatively straight-forward guide to Pathfinding and Chasing here:
https://developer.apple.com/library/ios/documentation/General/Conceptual/GameplayKit_Guide/Pathfinding.html#//apple_ref/doc/uid/TP40015172-CH3-SW1

It’s aimed at iOS and Swift, but the logic still applies.

Not a direct answer, but it may get you looking into the correct direction.

HTH,
Tim
Post by Jon Ogden
You know the coordinates of the hero right?
So calculate a vector between the enemy and the hero. Have the enemy move along that vector.
Post by ER
Hi,
How do I get the enemies "chase" after the hero ?
Right now I have one enemy on screen and moves until it hits a wall or whatever
then randomly chooses a new direction to go. Which is ok but dull, and robotic if you will.
I would like the enemies to chase after the hero but don't know how to do that.
Enemy(1) is the array with current enemy.
Thanks.
_______________________________________________
_______________________________________________
_______________________________________________
Unsubscribe by sending a message to:
<nug-***@lists.xojo.com>

List
ER
2016-09-13 01:44:55 UTC
Permalink
Post by Tim Jones
Path determination and assignment is one of the more frustrating
elements in game mechanics. Especially if you have a lot of
obstacles on the map that the characters must take into consideration.
https://developer.apple.com/library/ios/documentation/General/Conceptual/GameplayKit_Guide/Pathfinding.html
#//apple_ref/doc/uid/TP40015172-CH3-SW1
It’s aimed at iOS and Swift, but the logic still applies.
Not a direct answer, but it may get you looking into the correct direction.
Ah I see. I'll take a look at it.

If it becomes to problematic I cloud just turn it in to a side
scroller a not have to worry much about that or
just make dumb enemies. HA!

Thanks.



_______________________________________________
Unsubscribe by sending a message to:
<nug-***@lists.xojo.com>

List Help: <***@xojo.com>

ER
2016-09-13 01:39:03 UTC
Permalink
Post by Jon Ogden
You know the coordinates of the hero right?
So calculate a vector between the enemy and the hero. Have the
enemy move along that vector.
Ah. ok.

Don't know much about that, have to look it to that.

Thanks.
_______________________________________________
Unsubscribe by sending a message to:
<nug-***@lists.xojo.com>

List Help: <***@xojo.com>
Continue reading on narkive:
Loading...