The Daily Click ::. Forums ::. Non-Klik Coding Help ::. Activating and not activating enemies
 

Post Reply  Post Oekaki 
 

Posted By Message

Demon Lizardman



Registered
  05/08/2008
Points
  202

VIP MemberWii OwnerI am an April Fool
1st January, 2009 at 01:24:34 -

Ok, I need help in a game I am working on. Say, when the enemy is not on screen, it stops. But when it is on screen... It starts moving. I tried doing that but it doesn't seem to work.

 
Lets fly off into nowhere

Silveraura

God's God

Registered
  08/08/2002
Points
  6747

Game of the Week WinnerKlikCast StarAlien In Training!VIP Member360 OwnerWii OwnerSonic SpeedThe Cake is a LieComputerChristmas Tree!
I am an April Fool
2nd January, 2009 at 04:11:08 -

Try using a directional extension or the distance formula to detect how far you are away from enemies, and then toggle a flag on and off if you're within a specific distance. If that flag is toggled on, they'll move around and if it's toggle off then they'll stop moving.

Distance = SquareRoot( (X2 - X1)^2 + (Y2 - Y1)^2 )

 
http://www.facebook.com/truediamondgame

Ricky

loves Left For Dead 2

Registered
  28/12/2006
Points
  4175

Has Donated, Thank You!Game of the Week WinnerVIP MemberWii OwnerHero of TimeGOTM Winner! - November 2009I am an April Fool
2nd January, 2009 at 06:25:21 -

Brandons way would be best,

you could also try ticking "inactive when to far", however i noticed that mff doesn't completely make it inactive.

 
-

easyname



Registered
  15/04/2008
Points
  450
2nd January, 2009 at 10:13:38 -

You could check X and Y co-ordinates compared to an object on the middle of the screen, then set a flag on if the enemy is within those boundaries or something.

 
n/a

Silveraura

God's God

Registered
  08/08/2002
Points
  6747

Game of the Week WinnerKlikCast StarAlien In Training!VIP Member360 OwnerWii OwnerSonic SpeedThe Cake is a LieComputerChristmas Tree!
I am an April Fool
2nd January, 2009 at 21:14:52 -

I think it would be a lot more efficient to have a single value that tracks the distance of the player from enemies rather then have 2 values constantly scanning for the middle of the screen.

With my method, simply give every enemy object an alterable value that tells it how far it is away from the player, and if that value raises above a specific amount, then just disable it.

Here is an example of using my method. Fully commented.
http://arcanetale.sitesled.com/DistanceExample.mfa

 
http://www.facebook.com/truediamondgame

DeadmanDines

Best Article Writer

Registered
  27/04/2006
Points
  4758
5th January, 2009 at 11:51:43 -

Best way follows, assuming you're using MMF:

MMF objects have a condition under the 'Position' group (where you would click to test position for an object leaving or entering the play area).

Select 'Object is getting close to window edge'

This is normally used to alert when an on-screen object is nearing the window edge (i.e. about to leave the screen but hasn't yet).

It asks you to tell how close to the window edge it should run true. Enter a MINUS FIGURE, such as '-100'

This will return TRUE for any objects which are onscreen, OR offscreen by 100px.

You can NEGATE the condition to match all objects who are offscreen, except the ones who are within 100px of the window edge.

This is uber useful as you can disable objects when they're a long way offscreen, but can also make sure that they come alive just offscreen, giving them time to settle into their AI again.

It's always worked wonders for me

 
191 / 9999 * 7 + 191 * 7

Silveraura

God's God

Registered
  08/08/2002
Points
  6747

Game of the Week WinnerKlikCast StarAlien In Training!VIP Member360 OwnerWii OwnerSonic SpeedThe Cake is a LieComputerChristmas Tree!
I am an April Fool
6th January, 2009 at 04:31:25 -

That actually sounds like a very solid method, since you have such tools at your disposal in Multimedia Fusion 2. My suggestion was more raw and exposed to simple logic.

 
http://www.facebook.com/truediamondgame
   

Post Reply



 



Advertisement

Worth A Click