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

0 favourites
From the Asset Store
2D fighting template based in the game that defined the fighting games genre.
  • 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"

    This has its own challenges, I dont recommend you go that route as it can cause you a lot unnecessary problems, because when you compare (Family Vs Family1) you gonna pick yourself so you will need a lot of filtering to exclude yourself from the Picking list, either for LOS checks or for any other events that you will need to compare (Family Vs Family1)

    But if you think you can handle then go for it and try it. This is normally for advanced users, who will know how to debug and resolve things.

    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

    The "For each" is needed as the event has to run per instance to check if it has LOS to enemies and then Pick the nearest.

    Remember the example I gave you is just for demonstration of how to resolve the first issue you had about picking a turret target without adding the whole family as a target as you lose the filtering by teams, therefore you put the whole family as a target.

    Since there are only a few objects for demonstrations in my example I dont need to do any extra filtering or performance tricks. But in your case, if you gonna have 200+ enemies you gonna have to adapt the events according to your game. This has to be done on your side as only you know what you have in the game.

    The most common issues with the performance you can resolve them by (Filtering more the Picking & dont Run the events every tick)

    Example:

    Every 0.5 seconds

    Family1 is on Screen:

    ---------->Family1 has LOS to Family2

    ------------>Etc...

    https://www.construct.net/en/make-games/manuals/construct-3/project-primitives/events/how-events-work

    I honestly never use the Turret as you can replicate it easily with the LOS behaviour and you have the freedom to filter and pick whichever you need.

    For example:

    Remove the Turret and you can do something like this

    Then:

    You just have to add some events to make sure you rotate towards Family 2.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • tarek2Can you help me with this? It's similar to the positioning you teach me

    How can I make it stop when I touch the grid, (which is tiled background) Will it be positioned correctly instead of off-screen?

    I was using this format

    -on touch grid

    System create at (round(touch.x touch .Y) -48

    round(touch.x touch .Y) +48

    Etc...

  • tarek2Can you help me with this? It's similar to the positioning you teach me

    How can I make it stop when I touch the grid, (which is tiled background) Will it be positioned correctly instead of off-screen?

    I was using this format

    -on touch grid

    > System create at (round(touch.x touch .Y) -48

    round(touch.x touch .Y) +48

    Etc...

    Honestly, I have no idea what you are trying to do:

    1-This code doesn't place an object in a grid:

    round(touch.x touch .Y) 

    As it just rounds the positions of the Touch XY. So just here I'm already confused about what you are trying to archive. I thought you were trying to place all your objects in a grid?

    Perhaps you meant:

    floor(Touch.X /48) * 48 
    floor(Touch.Y /48) * 48
    

    This places any object in the World Grid which has Tile (size = 48)

    This is assuming that the Origen Points of the objects are at the Top-Left otherwise you will need to adjust it slightly.

    2-Spawning Objects:

    Assuming that you are already positioning and centring the Touch XY correctly in the grid as I showed above then you can just use:

    Example:

    Variable = X
    Variable = Y
    
    Set X = floor(Touch.X /48) * 48 
    Set Y = floor(Touch.Y /48) * 48
    
    Spawn Object at (X - 48, Y)
    Spawn Object at (X + 48, Y)
    
    

    You dont need to round it again as you already centred the Touch XY variables.

    3-How can I make it stop when I touch the grid, (which is tiled background)

    3-How can I make it stop when I touch the grid, (which is tiled background)

    Here I am not really sure what you mean:

    Do you mean stop the full loop?

    Do you mean Dont create the current object?

    Something else?

    I am gonna assume that the problem is when you're trying to create an object you dont want it to be created inside the grid right?

    That means that you want to create objects only outside the Tiled BG grid.

    Though am confused as to why you use "-on touch grid" if you just want to create outside the grid.

    But since you asked:

    You can use for example the system:

    "Pick by overlapping point"

    Make it the Top parent condition

    Pick by overlapping point (Tiled BG) (X -48, Y) --------> And Inverted Negative
     -----> Spawn Object at (X - 48, Y)
    
    Pick by overlapping point (Tiled BG) (X +48, Y) --------> And Inverted Negative
     -----> Spawn Object at (X + 48, Y)
    
    
    

    Now, I have the feeling that you meant to ask:

    How can I create only inside the grid and "stop when is not Touching the Grid" instead of "is touching the grid" as that makes more sense to me.

    Use the same code but dont invert it.

    Pick by overlapping point (Tiled BG) (X -48, Y) 
     -----> Spawn Object at (X - 48, Y)
    
    Pick by overlapping point (Tiled BG) (X +48, Y)
     -----> Spawn Object at (X + 48, Y)
    
  • tarek2 Sorry if it's a little confusing,My English is not very good, but here's an example of how I want it to work based on the example in the video I made.

    youtube.com/shorts/0G2LS_-WJH0

  • tarek2 Sorry if it's a little confusing,My English is not very good, but here's an example of how I want it to work based on the example in the video I made.

    https://youtube.com/shorts/0G2LS_-WJH0?si=-k6w0_Cdzg-6jUIB

    Hoh, that is a totally different question, forgot about what I wrote Avobe.

    The best thing to do if you struggle to explain an issue is just make a video as you did or use pictures as that helps a lot.

    https://www.dropbox.com/scl/fi/law61d0jyxzbbwuh8xbb1/Position-a-Grid-of-objects-inside-another-Grid.capx?rlkey=e916zytgmwacjc4uhhg3rx9u7&dl=0

  • tarek2 The blue balls are separated, so I'm having trouble creating them, I would like you to create 9 objects and adjust the grid

  • tarek2 The blue balls are separated, so I'm having trouble creating them, I would like you to create 9 objects and adjust the grid

    I think I already showed you that:

    Honestly, I'm scared to answer any of your questions as each time I resolve an issue there are 3+ more new questions to resolve that weren't part of the question. Im gonna have to take a break from this post.

    I think I already showed you that here:

    https://www.construct.net/en/forum/construct-3/how-do-i-8/hi-guys-help-positioning-183839#forumPost1113792

    What have you tried???

    There are so many options available:

    Use a Tilemap loop through all the tiles and spawn your tiles

    or

    Just loop through each tile of the tiled Background and spawn your objects

    You can sue the "For" loop XY

    For "Y" From 0 to (Base.Height/48)-1:
    ----> For "X" From 0 to (Base.Width/48)-1: 
    ------------> Spawn object at:
    ------------> X = base.BBoxLeft + (48 * loopindex("X"))
    ------------> Y = base.BBoxTop + (48 * loopindex("Y"))
    
    

    or

    Uses (Hierarchies & Temples)

    1-Create a Grid_Base for the objects, this will be the Parent and the Temple to create at Runtime

    2-Set the 9 objects in the Grid_Base object

    3-Add the objects to a Hierarchy with the Grid_Base object and make the Grid_Base as Parent

    4-Make the Grid_Base Object as a Temple and call it any name you like:

    for example "Grid Of Objects"

    5-Now to create the objects:

    on touch Grid 
    --------> Create Temple "Grid Of Objects" & Create Hierarchy = Yes
    --------> Set the Position as I showed you
    --------> Grid_Base remove children
    --------> Grid_Base destroy
    

    You are left just with the objects inside the grid

    There are many more ways... Good luck

  • tarek2It's still a little confusing, I'll try, this is very difficult, I'm trying everything, but it's difficult to do this by creating 8 objects and adjusting them to the grid 🙁

  • tarek2It's still a little confusing, I'll try, this is very difficult, I'm trying everything,

    but it's difficult to do this by creating 8 objects and adjusting them to the grid 🙁

    dropbox.com/scl/fi/h2zhtxyg892gccasti18m/Position-a-Grid-of-objects-inside-another-Grid2.capx

  • Thank you so much for the help again, you are a star at understanding this

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