0 Favourites

How do I choose a specific instance based on lineofsight

  • 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?

  • Construct 3

    Buy Construct 3

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

    Buy 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:

    (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:

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

    Thank you so much!

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