The Daily Click ::. Forums ::. Klik Coding Help ::. Baddie shoot at Goodie when close.
 

Post Reply  Post Oekaki 
 

Posted By Message

eyeangle



Registered
  12/06/2003
Points
  1683
5th July, 2007 at 04:04:27 -

I need my Baddie to Shoot at the Payer when it's 200pixles close to it. Either on the right, left, top or bottom.

What equation do I use to get this effect?

Thanks.

 
theonecardgame.com

waffleton



Registered
  20/04/2007
Points
  794
5th July, 2007 at 04:37:11 -

Either check the total distance between the two objects( and then run the shooting-events if it is less than 200, duh ), or use a big-ass detector object to check if it overlaps with the baddies/player.

There was a thread about checking distances earlier, that should tell you all you need to know;
http://www.create-games.com/forum_post.asp?id=192940

Or you could just check the baddies x/y position compared to the players position.
Meh, whichever method you prefer.

 
n/a

Del Duio

Born in a Bowling Alley

Registered
  29/07/2005
Points
  1078

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!Evil klikerHasslevania 2!The OutlawSanta Boot
5th July, 2007 at 13:12:21 -

The Advanced Direction calculator can help with distances between two objects.

I use a big invisible active object square that always follows the player at a certain point at the top-left, so that it looks like the player's in the center of a big gray square. When the enemy overlaps this invisible square, it shoots at the player. It acts like a line of sight. Really simple and it works great.

So, I second the big-ass detector object mentioned above.

 
--

"Del Duio has received 0 trophies. Click here to see them all."

"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"

DXF Games, coming next: Hasslevania 2- This Space for Rent!

eyeangle



Registered
  12/06/2003
Points
  1683
5th July, 2007 at 22:41:30 -

I don't want to have to use the detector only becasue it will have to be huge in some levels and I don't want the game running any slower.
I'm still having troubles with the distance between the two and don't exactly know how to tell the events what I'm trying to do.
I want the 'Baddie Man' to shoot every half second at the 'Sprite' when 200 pixels close in a circle radius, but how do I do this event? I can get the seconds part but not the first part.

 
theonecardgame.com

viva/volt

Awesome Sauce

Registered
  26/08/2006
Points
  1694

Game of the Week WinnerSilverNova MemberKlikCast StarVIP Member
6th July, 2007 at 00:07:53 -

Abs (Sqr(((X( "Enemy" )-X( "Player" )) pow 2)+((Y( "Enemy" )-Y( "Player" )) pow 2))) = 200 -> Shoot at player.

Change the names to whatever your instance names are and use the Compare Two General Values function.

(This is basically just Pythagorus)

Here's a good article: http://create-games.com/article.asp?id=1790



 
Image
http://bfollington.tumblr.com

eyeangle



Registered
  12/06/2003
Points
  1683
6th July, 2007 at 01:08:06 -

Thanks for that Ben, your equation was almost perfect. I just had to say <= 200.

My second question is, and I don't know if it's possible. But for the Baddie to shoot the Player only when there is nothing between them such as a wall or a box.

Thanks.

 
theonecardgame.com

»xerus



Registered
  28/06/2002
Points
  675

You've Been Circy'd!Game of the Week Winner
6th July, 2007 at 01:30:44 -

You could try doing something like collision masks I think. But I dont know the specifics, sorry ;(

 
n/a

Joe.H

Evil Faker

Registered
  19/08/2002
Points
  3305
6th July, 2007 at 06:14:58 -

Create a detector bullet that shoots constantly (only 1 at a time), when the player is in range, and if it reaches the player, start following/shooting at him.

If it hits something, don't.

 
My signature is never too big!!!

DeadmanDines

Best Article Writer

Registered
  27/04/2006
Points
  4758
7th July, 2007 at 16:41:33 -

http://www.mmfwiki.erathean.com/index.php/Line_of_sight#Particle_Method

Have yeself some fun

Move Safely 2 Object is great for this.

 
191 / 9999 * 7 + 191 * 7

eyeangle



Registered
  12/06/2003
Points
  1683
8th July, 2007 at 23:05:00 -

I can only find this object for MMF and not MMF2.

Would there be one for MMF2...?

 
theonecardgame.com
   

Post Reply



 



Advertisement

Worth A Click