How can I make the enemies always walk towards "Player" and when they hit "Player" they'll attack.
And if I play two player, They'll go and attack the nearest character.
Please help, Thanks
Printable View
How can I make the enemies always walk towards "Player" and when they hit "Player" they'll attack.
And if I play two player, They'll go and attack the nearest character.
Please help, Thanks
* Distance between enemy and player < Distance("Advanced Direction Object", X("enemy"), Y("enemy"), X("player 2"), Y("player 2"))
--Look at 0, 0 of player
* Distance between enemy and player 2 < Distance("Advanced Direction Object", X("enemy"), Y("enemy"), X("player"), Y("player"))
--Look at 0, 0 of player 2
* Enemy overlaps player
OR
* Enemy overlaps player 2
-- Attack
How do I do the "Distance between" condition?
Advanced Direction Object :)
And where is that, I've checked the objects menu and conditions.
http://ext.neatwares.ath.cx/ext/Advanced_Direction_Object :)
Seriously, isn't there any other way?
Well if you set an enemy to ball movement you could have it always look in direction of player. Then when it collides with the player have it attack or whatever you want.Quote:
Originally Posted by PimeX
You could use the actual distance formual instead of the expression from the Advanced Direction Object. However that's more of a hassle, why don't you want to use the ADO?Quote:
Originally Posted by PimeX
I think it might be like this ...
Distance = Sqr((X("Item1")-X("Item2"))*(X("Item1")-X("Item2")) + (Y("Item1")-Y("Item2"))*(Y("Item1")-Y("Item2")))
Is there a 'square' for MMF? I mean 'squareroot' is Sqr in MMF?
Sqr() is the MMF2 Square Root function, yes.
Yep, that's the best way I can think of.Quote:
Originally Posted by RickyRombo
I don't use extensions alot, so I always use a bouncing ball enemy. Use something like;
If you want the enemy to only chase the player when he is near the enemy, use a "Line of Sight".Code:-->Every 50 hundreths of a second
== Enemy -> Look in direction of player.
Create a wide, colored in circle that is semi-transperant, with its origin at the middle.
Then;Code:--> Always
== LOS set pos to 0,0 of player
If not overlappingCode:--> Enemy overlaps LOS
++ Every 10 hundreths of second
== Enemy movement start
== Enemy direction look in direction of 0,0 from player
*or*Code:--> NEGATE Enemy overlaps LOS
== Enemy movement Stop.
The top means the enemy stops dead, the bottom makes the enemy wander around.Code:--> NEGATE Enemy overlaps LOS
++ Every 90 hundreths of a second
== Enemy movement start
== Enemy set direction to Random(32)
You will also need;
Its a lot of code, but it should work for a bouncing ball movement. I use it a lot in my work for enemies that chase the player, but then stop and lose interest when the player runs away.Code:--> Enemy collides with backdrop
== Enemy bounce.
Yup... but guess there is no 'square' in MMF. We just need to multiply it again with the same item. :D
What do you mean there is no square? This squares a value:
Value pow 2
EG (5 pow 2) = 25
Sqrt()turns out its Sqr()
The above formula is slow, I recommend using the Advanced Direction Object or Clickteam Movement Controller to calculate the distance, as I stated earlier
EDIT: JEEZ! I came back to see this an a whole bunch of posts had beaten me...
Thanks LB... didn't know pow exist :D Silly me...
RickyRombo, yup I recommend using the Advanced Direction Object too...
The Advanced Direction Object is usable in normal Application, Java and Flash too...
In MMF2 it is Sqr()Quote:
Originally Posted by RickyRombo
How do I do it with Advanced direction object? Got it working