[Solved] How do I use LOS with Family of same objects?

0 favourites
  • 10 posts
From the Asset Store
A collection of various zombie characters sprites for creating a 2D platformer or sidescroller game
  • I've read everything I can find on picking Family instances and I honestly don't see how I can do this...

    I can't pick two Fighters in same "Fighters" Family, determine if the first Fighters has LOS to second Fighters, then if second Fighters.IsFoe (inst var) is True, set second Fighters to visible. I tried the two families trick, Fighters_1 and Fighters_2, this could work if you were allowed to have the same Fighter.Foe inst var on both families. But you cannot.

    I think this may be impossible in C2

  • I don't think this one is going to happen

  • There are no easy way to do it in C2, at least that I know of. But there are lots of way you could go about it regardless.

    For instant what I can just think of might be the easiest is to make a dummy sprite. Then right before you have to check for LOS you set dummy position to the to the target position and then you store the UID of the target Fighter with the dummy so you can easily pick it again later should you need it. Then you check LOS vs the dummy instead.

    Or you can do it the other way around which is probably even better, set the dummy to the one you want to check LOS for, and then do a:

    Dummy.Test_UID = Fighter.UID

    Fighter.UID <Not equal> Dummy.Test.UID //That will select all fighters except the one you want to check LOS for.

    Dummy check LOS to Fighters

    That is two ways to go about it, the last one is probably the best one in my opinion.

  • The dummy sprite idea is pretty good. Had not thought about that. Thank you nimos100 !

  • The dummy sprite idea is pretty good. Had not thought about that. Thank you nimos100 !

    u can do this, create on the family sprites u have a uid variable, and when is created save that uid, remember the first uid of the main sprite u have on screen unless u delete it, then when u want to select 2 of them just call the last uid - 1 or +1 depends witch ones u want to choose, but i think there is a better way then that, to your problem not sure what u try to achieve, if u can do a small capx with a simple sprite family and code ur selection code of family we could fix it for u a bit

  • When I move on of my game Tokens to a new spot, I want to check to see if an enemy Token is in LOS. If it is, set it to visible. My idea was to iterate every Token with Token.Foe = true and check LOS to just those tokens, skipping my own Tokens.

    My compromise is I don't bother with checking LOS to just Foes. It's checks LOS to all Tokens. So mine as well. Which is fine for now, but it doesn't feel right :-/

  • Try Construct 3

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

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

    I wrote a tutorial a while back on picking instances within the same family.

    https://www.scirra.com/tutorials/556/understanding-picking-with-respect-to-families

    Here's a quick picture of how to do what you're asking:

    You have to pick instance A, and save the properties you need to temporary local variables, *then* pick instance B.

    So this is what your code might look like:

  • cacotigon I did read your tutorial. It's very good

    I suppose I was hoping for something not involving any dummy objects or extra variables. Appears they are necessary to do this.

  • Hello everyone, hello Locohost,

    I'm on this at the same time, trying to find a simple and clear way. So I tried different things, but I got half satisfaction cause it's a trick and not a native function of Construct 2. So in a large project, using tricks would be confusing.

    In my project I got a general family of entity and I'd like them to be able to chase (chaze ?) or follow each other. Barely the same with your fighters.

    If you find a cool way to do this, can you share it please ?

    It seems like dummy object is a solution, but it involves creating more and more objects. Ok this dummy doesn't need cpu intensive calculation like collision, and it is invisible in the game, so no extra draw. In my project and because of the family behavior and the difficulty to make "complex" interactions between two members of the same family, I got lots of these kind of solutions. I came to Construct 2 with knowledges in programming languages and game programming. With an engine of your own, you can have references to two entities in the game inside the same function to apply modifications on both simultaneously. Hard to do that in Construct 2 without breaking the event system optimisation (lots of picking, and reset picking list), or doing something unreadable.

    If you find a good solution, I'm in for sharing

    Good luck and sorry for my english might be incorrect, not precise, or really strange sometimes.

    Nabu

  • Hey

    I think the dummy object that has all the same attribs as the Fighter family is the idea. Then in the first Family Pick event, it will by my Fighter, I'll store his data in the dummy Fighter. Then in second Family Pick event, I'll be picking enemy Fighters. I think this should work and is not too much of a hack

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