How to move sprites to the other object at distance and shoot asynchronously?

Not favoritedFavorited Favorited 0 favourites
  • 3 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • The idea sounds easy, but there is a catch. Turret behavior and a Line of Sight are calculating distances from object A to B based on the sprite's origin point, right? Because of that, in case an object A (enemy) is a sprite with an attack range of 10 and it's in the middle of the square object B (base) with size 20, he will shoot 20/2=10 and 10-10 will be the perfect min range. In case object A is on top or on the bottom of object B, then the attack range will not be enough because it's calculated diagonally. I tried to avoid behaviors and made it custom, but there's another problem. I found a solution to calculate distance, but object A is attacking object B synchronously, even if those family members have different variables for attack speed.

    Please, someone explain to me how I can make it work with turret behavior to calculate distance not based on image point and/or where my mistake is with attack speed.

    https://www.dropbox.com/scl/fi/i1k089qaxhs16b9yt6n6r/Attack-the-Base-in-Line.c3p?rlkey=bu5a941jw1yilg9622vnloeo7&st=8pg296yn&dl=0

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi.

    You have all the necessary variables for each warrior, so we can create for him an artificial intelligence that will search for a base and attack it by itself without ready behaviors.

    But Construct3 has great turret and movement behaviors so our AI will use them. And so it will be very simple, it will check if the warrior has reached the base at the attack distance and if it has reached the base, it will disable the movement behavior and turn on the turret.

    I also added a little attack particle just to see who is attacking. The range of the turret can be set large for example the area of the warrior's gaze, as it will still be turned on only when the warrior reaches the attack distance.

    Conclusion - every warrior should always be given a mind, even if it will be primitive and consist of two positions.

    I hope I have understood your goal correctly.

    fex.net/s/pbyostz

    Subscribe to Construct videos now
  • Hello igortyhon, sorry for late answer. Your idea of combination two methods is great (set turret range to Ally.viewDistance), thank you very much!

    C3P https://www.dropbox.com/scl/fi/jdv8emglv3abiy79xl6lm/Attack-the-Base-in-Line-3.c3p?rlkey=brpv5og7ws9kd3jxjgeb9i5d5&st=clzeakr1&dl=0

    Here is my updated version, if one of your website users or any other will need it. Some cpu resources saving that local Sensei dop2000 taught me.

    P.S. igortyhon If will be very good if there will be sorting by data on your website (so users can check new material) Thank you again, and have a good day!

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