How do I make an object move to nearest object of a family in a range?

0 favourites
  • 3 posts
From the Asset Store
112 High-Quality destruction sounds for videogames
  • I have a Shock Chain bullet which should jump to the nearest enemy after hitting a target. After it hits an enemy, it spawns an invisible ellipses range sprite hitbox on the enemy and checks to see if it is overlapping any other members of the enemy family. If it is, I want it to pick the nearest one and move to it using the move to behavior.

    I found the "pick nearest/furthest" condition under the "size and position" conditions and set it to pick the nearest Enemy family instance to the x and y of the hitbox. But now I am having trouble figuring out how to make the bullet move to the instance that has been picked by the condition. There doesn't seem to be an obvious way to actually return which instance is chosen by the condition. How are you supposed to do anything with the information the condition gathers?

    There must be something obvious about this that is going over my head, but I can't figure it out.

  • You can achieve this using Line of Sight

    Using LOS you can trigger an action when "Object A" near (range) to "Object B" do that.

    Check this editor.construct.net

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I found the "pick nearest/furthest" condition under the "size and position" conditions and set it to pick the nearest Enemy family instance to the x and y of the hitbox. But now I am having trouble figuring out how to make the bullet move to the instance that has been picked by the condition. There doesn't seem to be an obvious way to actually return which instance is chosen by the condition. How are you supposed to do anything with the information the condition gathers?

    when you pick nearest on the action on that condition you need to create the bullet, and set its angle towards that picked family member. you can't otherwise... i mean you can but you need to save the position of picked family member into some array or variables then create the bullet and set its motion angle etc... depends on what you need the bullet to do, if its one bullet or multiple bullets, like continuous shooting.

    you can also have 1 variable and pick the familly by its value, like IID ... save the family object IID into a variable, then use on shooting create object at gun position then a subevent and pick by evaluate the family.iid with the variable value you saved before, and then create the bullet and set the angle towards that position of the mathcing family iid = value

    here is a example of what i "burfed" above.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)