Please help, Its melting my BRAIN!!!

liamoliamo Member Posts: 191
edited November -1 in Working with GS (Mac)
Hi guys, can you help me, I am spawning some actors in my game, but I don't want them to spawn together, they are all instances of the same actor (pit) and I want them to not spawn anywhere in a certain radius around the actor, please help.

Comments

  • lildragnlildragn Member Posts: 105
    Someone might be better able to help, but what have you tried so far? Have you tried using a timer?
  • liamoliamo Member Posts: 191
    the spawn itself is random, and the spawn timer is also random.
  • liamoliamo Member Posts: 191
    Bump
  • okkleokkle Member Posts: 32
    I haven't tested this, but this is how I'd try and do it:

    Make the actor that is spawning Pit follow the actor that you don't want Pit to spawn within a radius of (assuming that actor moves, otherwise just place it on top).

    Then when that actor is spawning Pit, set the spawning position as 'relative to actor' and set it up so they spawn within a random distance, the minimum value being the radius you want to keep clear around your other actor, and the maximum distance however far out you want them to go. So if the min random value is 150, you should always get at least 150 pixels between Pit and the actor in all directions.

    Like I said, I've not tested it, but in my head that's how I'd try, it might need some fine tuning and more precise maths, but it should be a start.
  • liamoliamo Member Posts: 191
    Cheers okkie, I'll see, but the pit spawner doesn't move and as there are multiple instances of the same actor, I cannot use constrains otherwise the computer will get muddled up and Gamesalad will probably crash.
    Liamo
  • liamoliamo Member Posts: 191
    Double bump
  • liamoliamo Member Posts: 191
    Triple bump, please help
  • MagoNicolasMagoNicolas Member, PRO Posts: 2,090
    VEry Simple,
    A rule on the Spawn item.

    If Collide With (The Same Actor)
    Then Destroy.

    then you WONTt Have them spawn on the same spot.

    Cheers.
  • liamoliamo Member Posts: 191
    Thanks, but I've done that, what I want is for the pit to not spawn in a certain radius around another pit.
    Liamo
  • liamoliamo Member Posts: 191
    Triple bump, please help me, somebody.
  • cbtcbt Member Posts: 644
    Here it goes;

    create 2 real attributes
    ranX
    ranY

    on pit;
    create self boolean attribute "do_it"

    when "do_it" is true;

    change attribute game.ranX to "random(100,300)"
    change attribute game.ranY to "random(100,300)"
    spawn "pit" to coordinates
    ranX
    ranY

    Timer, after 0.05 seconds change self.attribute "do_it" to false

    Now;

    on pit, if colliding with "pit" change "do_it" to true.

    -*-*-*-

    And start the actor with "true" is checked. And let me know how this does. I have no idea. eheh
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    Try creating a 'spawnChecker' actor that will randomly search out an empty location for 'pit'. Once it finds a suitable location, 'spawnChecker' then spawns an instance of 'pit' and then destroys itself.

    Pit spawns 'spawnChecker' and 'spawnChecker' has the following behavior(s):

    Timer (every 0 seconds)
    --When actor overlaps or collides with actor of type pit
    ----Change Attribute: self.Position.X To: random (0,480)
    ----Change Attribute: self.Position.Y To: random (0,360)
    --Otherwise
    ----Spawn Actor pit, in front of actor, 0,0,0 relative to actor
    ----Destroy this actor

    I just tested it out and it works. It will randomly find place for pit until there is absolutely no place left for one to be placed. (However it does not stop, it keeps checking for a place forever if there is no space left for another one.)

    Hope this helps!
Sign In or Register to comment.