Is it possible, for a sprite to not attack itself when adding itself as a target?

0 favourites
From the Asset Store
Kids Game
$49 USD
New Sounds Added Update: 115 new sound effects added for no additional cost!
  • How do I make the blue sprite (using the turret behavior) attack itself only if it is on a different team using instance variables?

    Example:

    If a sprite sees another of the same type but with the instance variable set to team 1, it won’t attack. However, if the other sprite is on team 2, it will attack the copy of itself.

    I'm having a lot of trouble with this, could you send me a CAPX about it? 😰

  • Hi Amanda

    Will this help you?

    https://www.dropbox.com/scl/fi/d7xxwpil8ig6ft96dm687/1-Dont-Target-objects-from-the-same-Team.c3p?rlkey=z47eudlybobwvwzkxcv4rrg1n&dl=0

    The turret behaviour can be a bit tricky to set up.

  • Unfortunately I'm creating it in Construct 2, can you do this in it? Thank you so much for helping, I've been having a headache with this for months.

  • Unfortunately I'm creating it in Construct 2, can you do this in it? Thank you so much for helping, I've been having a headache with this for months.

    Is the same thing, they use the same events, nothing different.

    Just copy the events line by line in Construct 2, it should work.

  • Dude... THANK YOU SO MUCH!! I've been trying to solve this for months, thanks for the help!

  • Can you also tell me if it is possible in Contruct 2 to create a life bar for a family? Because it is not possible to add a container to a family with

  • If so, could you send me a CAPX?

  • Can you also tell me if it is possible in Contruct 2 to create a life bar for a family? Because it is not possible to add a container to a family with

    Containers dont work with families.

    You gonna have to create your own tracking system with UIDs or something similar to link the (Enemies Family + HealthBars)

    Here is a very basic example of how to create and link a health bar in C2:

    Basically just shows how to (Pin and link UIDs) using families.

    Is a long time since I dont create UIs in Construct2 and forgot how tedious the process was. Especially when you have been using C3 hierarchies for so long time, which takes care of all behind the scenes, it is as simple as building the HealhBar in the editor and just spawning it with the enemy creating a hierarchy. Also, the picking is simple, just pick Enemy childs. Few lines of code compared to all you have to do in C2 to get it working with UIDs etc...

    https://www.dropbox.com/scl/fi/gtj2nb73mcdwi6ov8lg6v/1-Health-Bar-That-Works-with-Family.capx?rlkey=fv045430xdv09n7s96qyntat9&dl=0

  • My God, you are a genius! Thank you so much again

  • tarek2 Do you know if I can add the family itself to attack if it is not the same one I had at once? Instead of having to add each LineOfSight shooter.

  • tarek2 Do you know if I can add the family itself to attack if it is not the same one I had at once? Instead of having to add each LineOfSight shooter.

    Hi

    I dont quite understand what the question is or what you are trying to do:

    In construct, you cannot change families!

    Or are you referring to teams?

    If you are referring to teams, then if you just change the team it will automatically attack any other team that is not from his team.

    Also, make sure you spend time trying to understand how the behaviours work, to have an understanding of the capabilities and limitations you will face, and then with the help of the examples that they provide you, you can learn how to circumvent any Limitations so you can make your own logic to tackle anything you wish to create.

    I didn't find the Construct2 manual but the C3 is still relevant at least for the common features that both share, excluding any new features that have been added to c3.

    https://www.construct.net/en/make-games/manuals/construct-3/behavior-reference/turret?utm_campaign=C3Editor&utm_source=browser&utm_medium=r391&utm_term=OpenManualLink&utm_content=BehaviorHelp

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • tarek2 I actually asked a bit confused hahaha, I meant that instead of adding each shooter to attack, add the "shooter_team" family to attack the "shooter team" family If they are not on the same team

  • tarek2 I actually asked a bit confused hahaha, I meant that instead of adding each shooter to attack, add the "shooter_team" family to attack the "shooter team" family If they are not on the same team

    It took me quite a long to understand what you are trying to do but I think I finally got it, or I hope so:

    So you are adding new object types to the project and you want to run one code base for all the objects through a family to avoid duplicating the same code for each object type?

    To do that and to simply the picking for yourself is to create two families instead of 1. Add the variable "Team" to both families, but since an object cannot have repeated variables call them "Team1" & "Team2" but keep in mind that is the same variable.

    Create:

    Family1 -------- and Add variable "Team1"

    Family2 -------- and Add variable "Team2"

    For every object that you add to the project, you need to include them in both families. And set their Team.

    For example, you add to the project "Shooter_3"

    Add "Shooter_3" ----------------- > to (Family1 & Family2)

    And Set "Shooter_3" Team variables to the exact same team name:

    For example, it is for (Team = 1)

    Set variable "Team1" = 1

    Set variable "Team2" = 1

    Another thing is, remember to do the same when you spawn any new instance, set both variables:

    Set variable "Team1" = YourTeam

    Set variable "Team2" = YourTeam

    https://www.dropbox.com/scl/fi/hybo21shepp9oytl26rvv/Turret-Dont-target-friends2.capx?rlkey=b16nywwasp80yaje3eiqsahx3&dl=0

  • tarek2 I thought about this system, but the game I'm creating is too big, and I would have to set a lot of settings for "team2"

    In this picture, can I replace something from (for each) to something lighter? When there are more than 20 objects in the game using this configuration in the image below, the FPS drops a lot.

    When I removed the "for each" for testing, even with 200 objects my game continued at 60 fps

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