is LOS add/clear objects global?

From the Asset Store
Globals 2.0
$3.99 USD
Globals 2.0 stores and group variables. You can also load and save data (variables) from/to JSON files.
  • I know I've had some really wonky issues with the Turret behavior when I added an object to Target, it would somehow work globally. I'm finding the same is true for Line of Sight. When I clear objects for a particular object, it clears them for different objects from the same family.

    Is this supposed to happen? am I using LOS clear objects wrong?

    The main issue I run into is... I have this one turret object and depending on which level you are in, sometimes that turret is friendly to the player, other times that same object is the enemy to the player. So I clear LOS objects at the start of each Layout and determine if those turrets are enemies or not and add them accordingly.

    Some strange things I'm seeing is somehow the LOS of the player is affecting the LOS of other objects within the family. But also LOS is sometimes just stops working. I feel like I am using it wrong.

    Any help?

  • On turret behaviour you are adding objects for the turret to target, on line of sight you are adding obstacles that block the line of sight. Maybe you are thinking about LOS in the wrong way.

  • Yes you are correct the LOS is Global

    Basically, even if you filter instances from the same object and then add to that picked one an obstacle it will be global for all the other instances of the same object.

    You can test it here:

    https://www.dropbox.com/s/ips3dsytougtljf/L.O.S%20Obstacles.c3p?dl=0

    If you notice at the start of the layout I pick only the first Green object at the Left and I add to it the obstacle but the obstacle will be added to all three instances as you can see the last two green instances will not turn yellow at the run time.

    This is by design.

    =================================================================

    However, One thing you could do but this may not work for all projects, it depends on what you have interacting with solids as it can interfere.

    Instead of use custome, you need to use solid if you can and then use the collisions filters to add obstacles to specific instances this way you will be able to do per-instance obstacles, it's a bit more work to do but at least it's an alternative and is not that much work.

    https://www.dropbox.com/s/ron6eojm8h6a0pw/L.O.S%20Obstacles2.c3p?dl=0

    Will be nice if we could use collision filters swell when using the LOS by custom obstacles or any other behaviours that you need to filter obstacles, maybe could be a feature request.

  • wow thanks tarek2 this is very helpful! do you know if it also applies to families? it seems to.

    I don't understand why out of the 3 Team2 sprites, the 2 to the right start as yellow.

    oh, also the issue I am having is with casting rays, not the bool HasLineOfSight. I'll try to replicate it.

  • do you know if it also applies to families?

    Yes, the family you can count as one single object so the same rules apply

    I don't understand why out of the 3 Team2 sprites, the 2 to the right start as yellow.

    I was trying to make you visualize that add obstacle are global

    Example:

    -In the first example I used the add obstacle the same as you did but I just added to the green instance that has the "boolean Active" true which is the First at the left

    But as you can see that doesn't work because the last two don't turn yellow at the Run time meaning that they will have LOS

    -In the second example we try the same thing but this time is working as I use the solid obstacle instead and collisions filters that's why you can archive per instance obstacle filter So:

    1-If its yellow it means they have LOS to the Team1 therefore the are no obstacles on the way

    2-If its not yellow it means they have No LOS to the Team1 therefore the is an obstacles on the way

    Meaning that each has their own obstacles independently on the second example

    oh, also the issue I am having is with casting rays, not the bool HasLineOfSight. I'll try to replicate it.

    It should work the same, as if you have an obstacle it will intersect

    I will recommend you test it out first in a small demo and see if it works because if you test it on your main project they may be a lot of other events of things interfering.

  • tarek2 > > do you know if it also applies to families?

    Yes, the family you can count as one single object so the same rules apply

    so that does that mean I can't have the same Family objects using a Family LOS behav and target each other?

  • tarek2 > > do you know if it also applies to families?

    >

    > Yes, the family you can count as one single object so the same rules apply

    >

    >

    >

    so that does that mean I can't have the same Family objects using a Family LOS behav and target each other?

    If you mean for example you have Family1

    And then you have events:

    Family1 has LOS to Family1

    That will cause you to target yourself so the LOS will be always true so nope that's not what you wanna.

    The same as Object1 has Los to object1

    To be independents and to not target yourself you need to use a family and a normal object

    Object1 has LOS to Family1

    Or a family that don't have the same objects on both sides Example:

    Family1 has Los to Family2

  • tarek2 okay, yeah I think I can see what is going on.

    it's pretty complicated the way I have things set up.

    but you see here I have a laser pointer for the turret, and a laser pointer for the ship, they keep going through each other, only one works at a time. And they share the LOS behav in the same family. (sorry I know its hard to see in the GIF)

  • tarek2 okay, yeah I think I can see what is going on.

    it's pretty complicated the way I have things set up.

    but you see here I have a laser pointer for the turret, and a laser pointer for the ship, they keep going through each other, only one works at a time. And they share the LOS behav in the same family. (sorry I know its hard to see in the GIF)

    It's hard to understand what's going just from that clip

    If you still having problems I think the best thing is to create a small separate demo of what you trying to do and someone can help you to see where the problem is otherways I'm a bit lost now of what you are referring or what you are trying to do.

    It will be much quicker to find your solution.

  • tarek2 yeah I did that to figure out what you were talking about.

    I was just showing you what I am working with. in some cases I use los to determine shooting and in other cases I am using it to determine length of a beam. The main issue is that its global and changes a different object's obstacles because they share the same family behavior.

    So when I clear obstacles for one, it clears them for all, which is NOT as advertised!

    you said this is by design. I wonder why? I'd much prefer a list of obstacles attached to one object. rather than applying it to all other object types in the family.

  • I would also love to be able to see a list in the debugger to see what obstacles a particular object has attached to it. But I don't see a way to do that.

  • "I'd much prefer a list of obstacles attached to one object. rather than applying it to all other object types in the family."

    That's what a family is used for. You can use the individual object if you don't want to apply to many objects.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I was just showing you what I am working with. in some cases I use los to determine shooting and in other cases I am using it to determine length of a beam. The main issue is that its global and changes a different object's obstacles because they share the same family behavior.

    So when I clear obstacles for one, it clears them for all, which is NOT as advertised!

    Hoh I see No worries, that's cool then

    you said this is by design. I wonder why?

    I guess it's for performance as it's easier to maintain just one list for all the instances than each instance having its own list but this is just speculation not sure if it's 100% accurate.

    Indeed I had the same problems in the past as LOS is one of the behaviours that I most used and I needed that too so will be nice if could have an update:

    1-Per instance obstacles (This one I guess it could be added easily as they already have collisions filters) so it should be the exact same thing but with custom objects

    2-LOS to Bounding box instead of just Origen point will be very helpful too

    I have never seen anyone requesting it on the official feature request so maybe you could try

  • lionz

    That's what a family is used for. You can use the individual object if you don't want to apply to many objects.

    right but when you have a bunch of different objects in a game that can shoot, and you setup all the different things you can shoot (13 different weapons and firing types) into families so you don't have to repeat events for each object type. This goes for a bunch of things I want my game objects to be able to do: collisions, become stunned, have health bars, muzzle flashes and many, many other things. But you still want them to be able to target each other as obstacles to stop a laser beam. Some will be friendly, some will not.

  • From what I am seeing in the gif and from what you described below particularly 'The main issue is that its global and changes a different object's obstacles because they share the same family behavior.' you should go for specific objects outside the family.

    Families are good for applying one thing to everything in the family to minimize redundant events but they're not good for doing the opposite and setting one family member with one option and another family member with another option, for this you should go onto specific objects which also will inherit the behaviours to be used from the family.

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