User Tag List

Results 1 to 5 of 5

Thread: Detect Object within a certain range

  1. #1
    No Products Registered

    Join Date
    Jun 2010
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Detect Object within a certain range

    So I have just started with MMF2 and I am trying to learn a lot of the basics. I have a game where I want the "bad guys" to chase my character. I figured I could do the "always+look in the direction of/blah blah" However, I want the "bad guys" to only chase me when I am within a certain range. I am by no means a programmer, but I understand some, so lamens terms when possible would be helpful. Thanks guys!

  2. #2
    No Products Registered

    Join Date
    Jun 2010
    Location
    Indonesia
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Detect Object within a certain range

    Make an active object and place it beside an enemy, and instead of using 'always' use 'player' is overlapping 'active'. (Sorry my english wasn't good)

  3. #3
    No Products Registered

    Join Date
    Jun 2010
    Location
    Sutton, Surrey, UK
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Detect Object within a certain range

    My way would be:

    Have a hidden circle thats always placed on your player. (This will be the range)

    If the enemy is overlapping the circle, then, like you said, do "Look in direction of/blah blah" xD
    Good luck!

  4. #4
    No Products Registered

    Join Date
    Jun 2010
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Detect Object within a certain range

    Thanks I will try those, I kept playing with it and I ended up doing a behavior on the "bad guy" that compared it X-position and then it would look in the direction of and start it's movement.

    I will also try your suggestions to see which fits best. Thanks!

  5. #5
    Clicker Fusion 2.5 Mac
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)iOS Export Module (Steam)

    Join Date
    Sep 2008
    Location
    Western Australia
    Posts
    256
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Detect Object within a certain range

    You could use Pythagoras' theorum to calculate the distance between enemy and player and react if distance is less than a certain amount.

    The distance that you need to calculate is the length of the hypotenuse (c); you know the lengths of the other two sides (a and b) of the triangle because you know the enemy and player x,y positions.

    c squared = (a squared + b squared)

    If you are just looking for the closest enemy to react, then I don't think you need to calculate the square roots, but I'd check it first in case my memory fails me!

Similar Threads

  1. Detect not exist the object that have specific value
    By ASD in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 3rd August 2012, 11:45 AM
  2. Event to happen when Object A is within a certain range of Object B?
    By Outcast in forum Multimedia Fusion 2 - Technical Support
    Replies: 11
    Last Post: 20th April 2012, 10:56 PM
  3. detect whether to drag a specific object
    By ASD in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 5th September 2010, 04:20 PM
  4. Replies: 2
    Last Post: 24th July 2009, 07:47 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •