How do I choose a specific instance based on lineofsight

0 favourites
  • 5 posts
From the Asset Store
Advanced inventory mechanics for your RPG game (Array-based). Take Items, split them, pick up them, read the description
  • So, I have an AI that pathfinds towards another AI and attacks them.

    The hunted AI is spotted by the hunting AI it sets an instance variable called PursuitDetection to one on the hunting AI. Every 0.5 seconds PursuitDetection is equal to one, it is supposed to find and move along a path towards that specific hunted AI that was detected. The problem is that the pathfinding selects a random hunted AI on the whole layout.

    Is it possible to, when setting a target for the pathfinding, to select the closest 'hunted AI'.X and 'hunted AI'.Y to the hunting AI?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Kind of confusing to me, but I have another problem that involves setting the angle of something every tick towards another instance, but it selects a random instance.

    So is it possible to select the closest instance to the player somehow? Like when you select the action it asks for an X and Y coordinate.

    Is there a way I could select the closest of that instance relative to the player through that?

  • Try this, under the sprite you want the nearest picked of, choose Event "Pick Nearest/furthest"

    Set the X & Y to the X & Y position of your player.

    Looking through examples I've posted in the past, there is also the turret behavior, that you could use to set the angle when the target is within range:

    https://dl.dropboxusercontent.com/u/854 ... Range.capx

    (this example is like zombies turning toward the player when within range, and slowly moving that direction.)

  • Try this, under the sprite you want the nearest picked of, choose Event "Pick Nearest/furthest"

    Set the X & Y to the X & Y position of your player.

    Looking through examples I've posted in the past, there is also the turret behavior, that you could use to set the angle when the target is within range:

    https://dl.dropboxusercontent.com/u/854 ... Range.capx

    (this example is like zombies turning toward the player when within range, and slowly moving that direction.)

    Thank you so much! <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy">

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