How do I check for targets without turret behavior

0 favourites
  • 12 posts
From the Asset Store
In this template the music plays without looping in your game
  • Guys, help is need so much.

    I need to check for targets to attack it, but basic turret behavior doesn't suit for me (it's impossible to manage targets with complex conditions).

    I solved this problem with "for each every tick" method, but it takes a lot of cpu work.

    Are there up-to-dated addons (or solutions) with turret behavior but more advanced and optimized?

  • So you're looking for a way to do...what? Give me an example of a complex condition.

  • For example:

    • I want use the same sprite for all units.
    • Unit has team.
    • Turret shouldn't target unit with same team value.

    Turret behavior doesn't work in this way (link to capx)

    drive.google.com/file/d/0B55PnHLHjkIGQ3lHRVRMNUsxUEU/view

    tarek2

    Thank you, I never thought in this way, but it doesn't work if I have the same sprite for player and targets.

  • In your example the target for the turret is the turret object itself.

    As a result, "Unit->On Turret target acquired" event works unpredictably because most of the times turret acquires itself as a target and stops scanning for other targets. This is what's causing all kinds of problems.

    And, I'm guessing, no "advanced turret" plugins will help here.

    You need to create two objects - Unit1 and Unit2.

    Set Unit1 as a target for Unit2 and vice versa.

    Add them both into a Unit family, define all variables/behaviors/effects on the family and everywhere in your game you can continue to refer to Unit as one object. Only it will be a family instead of a sprite.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
    • I want use the same sprite for all units.
    • Unit has team, which i can change during game proccess.

    Is it unsolvable problem?

  • With turret behavior and only one sprite object? Yes, I'm afraid it is unsolvable.

    I still think you can use 2 sprite objects and a family. When one unit changes team, you create a new unit in another team, copy all its properties from the first unit and then destroy the first unit. Shouldn't be too hard.

  • fens

    The way you wanna do it without Families and with one object will hurt performances a lot plus much more complicated but

    Will this be good enough performance?

    They don't shoot between the same teams, the teams are made of group of two

    Capx: https://www.dropbox.com/s/5n9i79fey96pjmm/Team%20Pick%20No%20Famlies.capx?dl=0

  • Yeah, this is I've been looking for )

    But it's same like: "I solved this problem with "for each every tick" method, but it takes a lot of cpu work."

    Guys, I don't catch how I should work with families. I didn't found any actions with inheritance (only clone).

  • I really don't get why you must use the same object for both teams.

    That said, you could get away with it by programming your own targeting behavior as funcytions and more specific conditions for targetting and shooting (every tick definitely won't cut it).

    Cheers!

  • can't you add the condition target.uid =/= self.uid ?

  • can't you add the condition target.uid =/= self.uid ?

    No, because "Unit->On Turret target acquired" is triggered only once when turret finds a new target and it stops scanning for other targets.

    AFAIK there is no way to tell the turret to forget the current target and look for the next one.

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