Objects relationship (distance)

seveksevek Member, PRO Posts: 30

Hi guys.

So I am working on a game which a character has to dodge obstacles and eat "foods" to gain levels.

I have five different types of obstacles that make things harder as you progress through the level.

There are two different food types that give different levels.

I am using a table to organize all the data.

However, I am having a bit of hard time with how to organize their relationship.

For example, at a higher level, there will be more obstacles and more foods. And they should not overlap with each other.

What do you think the best way to avoid overlap between the obstacles and foods? Is there an equation that can make sure that regardless of number of actors on the screen, they don't touch each other?

Thanks

Comments

  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408

    if you can tag them all, and then put a collide rule so they collide with actors with tag "XXXXX" they will bump into each other, but should never overlap

  • seveksevek Member, PRO Posts: 30

    That is a great idea. I will give that a try.
    Thanks :-)

  • seveksevek Member, PRO Posts: 30

    So, things are working well.

    When obstacles are randomly spawned, they are not overlapped, which is what I want.

    However, now they are right next to each other and I want to keep a minimum distance between them, so they are not right next to each other.

    I am thinking of using a table to keep a certain pixel distance between them when they are spawned.

    Or what do you think I should do?

    Thanks in advance!

  • SocksSocks London, UK.Member Posts: 12,822

    There are a million ways to space things in these kinds of scenarios, just use your imagination I'm sure you could come up with something interesting.

    For example you could spawn a slightly bigger actor (that is invisible) and in this bigger actor you place a rule to spawn the normally sized actor . . . (you could also place a little time bomb inside the larger actor - timer, after 1 second destroy this actor).

  • seveksevek Member, PRO Posts: 30

    I never thought about that way, using an invisible actor in that way. That is brilliant. Thanks man. I will give that a try

  • seveksevek Member, PRO Posts: 30

    So, here is an update.

    To make things simpler and easy to test, i made following rules.
    There are two bigger "invisible" actors which are spawned at a random location at the same time.

    Also, to avoid overlapping of these two actors (as they are spawned at a random location), I made a collision rule which they bounce if their spawning positions overlap.

    So far, these two actors never overlap.

    Then, I put the actual "foods" and "obstacles" to spawn inside of these two actors.

    Here is the problem.

    It seems like the main objects are spawned instantly even before these two invisible blocks bounce (the objects are spawned at the original place even if two invisible blocks were spawned and overlapped). check out the photo below.

    I am attaching dropbox photo link.

    **https://www.dropbox.com/s/78rj67t8nlqvp2a/Capture.JPG
    **

    Putting collision rule to these main objects are not working.

    Any suggestion?

    Thanks!

  • SocksSocks London, UK.Member Posts: 12,822
    edited June 2014

    Here's another way to do the same thing . . . . might be useful ?

    Link: https://www.mediafire.com/?6z55720588j8swk

Sign In or Register to comment.