Need help with random spawn actor

linkoslinkos Member Posts: 16
edited November -1 in Working with GS (Mac)
Hi everybody, and in advance sorry for my english (im french)

I have a problem to resolve, i hope that you'll could help me.

I want to spawn an actor somewhere randomly on my scene but i want to exclude a rectangular zone on this scene is it possible to do that?

My scene is 960x640 and i want to exclude a zone (190x158) who is placed at x:240 and y:155.

If someone could help me it will be very cool

Thanks in advance

Linkos

Comments

  • FloridaGamesFloridaGames Member Posts: 328
    spawn actor position x : rand(0, 960) position y : rand(0, 640)
    create an actor that covers your zone (190x158)
    if what youll spawning collides with the actor that covers the zone, destroy the spawn actor and spawn it again.
  • linkoslinkos Member Posts: 16
    Thanks a lot for your answer It work verey well now
  • linkoslinkos Member Posts: 16
    Humm i'm very sorry but i've another problem.
    Your method work fine but in fact it cause a new problem. The spawned actor is in mouvement and at a certain time it must cross the area but Logically it can't do now (if i destroy the actor on this area).

    I'm very sorry but do you know if there is another solution to prevent the spawn of my actor on this zone?

    Thanks in advance
  • OlsenOlsen Member Posts: 30
    Dont make the actor (area that you dont want it to spawn at) to destroy the spawning actor and spawn again, just add a collide behavior so when it is spawned on that area it gets moved off it. And so it doesn't collide with the area again after spawn just add:

    Timer
    For 1 or 2 seconds
    Collide with "the area actor"

    This will make it collide with the actor(area) only the 2 seconds after the spawn, and it will not collide with it later on.
Sign In or Register to comment.