Family Rotate Independently

0 favourites
  • 5 posts
From the Asset Store
A collection of various zombie characters sprites for creating a 2D platformer or sidescroller game
  • Hey guys!

    I'm trying to figure out how to make each member of a family rotate toward the closest member of the same family. Does that make sense?

    At the moment, the system just seems to realise that it itself is the closest member of the family, so it just looks at itself. This obviously isn't what I want it to do. I want to to exclude itself from the choices. I therefore tried to set it up so that it would allocate itself a number, and only check out family members whose numbers that were not equal to its own... but that's where I start to get confused, and it doesn't appear to be working.

    Originally I did have it set up where players and enemies had their own families, and that worked great. The only problem I had is that I wanted certain aspects to work for both families, so I combined the two. It is important that I only have this working within a single family, so I hope someone can help.

    I feel I'm close, but for all I know, I may be way off.

    In any case, please find the attached summary example of what I'm trying to achieve.

    Example

  • It seems what I'm actually looking for is "Pick second closest to".

    Still no idea though...

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I've had to make a copy of your family.( now there is a sentence I wasn't expecting to use today !)

    capx - who is closest to me who is not me

    because I have nested loop I have set this to only run every 0.05 seconds.

    drag and drop added to family1 so you can move them around easy.

    appears to work...

  • Thinking about this.

    If this was taken into a function and only called as needed it would help. Also once all the family objects have the right direction then this function could be reduced from checking all the family1 objects to only checking any that are moving...

    If you have 10 family objects then this will run 10*10 times - but if you only need to check 1 of the family then it would only need to run 10 times.

  • Brilliant! You've helped me loads lately, so thank you very much indeed.

    I've tweaked it slightly so that it will check the closest every 3 seconds to make it even less intensive, but it will retain the knowledge of who is closest and will look at them constantly (For at least 3 seconds).

    Very clever. It will take me a while to actually get my head around, but it works great so far!

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