Random locating actor

johanesadikajohanesadika Member Posts: 11
edited November -1 in Working with GS (Mac)
I'm going to place a lot of actors to be "obstacle" in this game..
But i dont know how to place it randomly ?
I figured out if i place it manually then this game such a bored.. Then i need a randomly placing this obstacles..

Anybody knows the solution ?

Comments

  • latygo60latygo60 Member Posts: 27
    You have to drag all the actors that you want on the scene, and inside every actor put a Change attribute: 'self.positionX' to 'random (min,max)' <-- lower and highest X values it can have.
    And the same for the Y if desired.
  • johanesadikajohanesadika Member Posts: 11
    thanks!!
    but if i want it more than 1 in the scene, how to do that?
    do i have to put the same actor a lot in a scene?
  • latygo60latygo60 Member Posts: 27
    it depends of the kind of game you want to do.
    If only a few are showing at the same time on the camera view, I'll try recycling the actors. This way, those who are off the view, can change his position to a new one (with 'Change attribute').
    Obviously, you could use spawning, but the problem is that increases the RAM usage and the loading time.

    If you explain the kind of game, I could be more precise

    Hope it helps
  • johanesadikajohanesadika Member Posts: 11
    Im going to make a game that the actor is running from top layer to the bottom layer and then there are a lot of obstacles that it has to avoid. the problem is the obstacle. how could it be randomize the number and location? I knew about the location problem because of you. The only one problem is the number of the obstacle. hmm..
  • latygo60latygo60 Member Posts: 27
    Just have to make an attribute to control the number 'HowMany'.
    Create an actor that will spawn the obstacles 'Generator', and drag it on the scene.
    In this actor make a Change attribute 'HowMany' to random(min number of actors,max number of actors).
    Inside this actor, also do the Spawning.And every time you spawn an obstacle Change att 'Howmany' to 'howmany-1'
    You can make the Generator actor all screen tall and wide and make it invisible, and when the game starts the obstacles will appear in random locations and number.
    I think this should work if the game isn't scrollable.

    Hope it helps.
  • johanesadikajohanesadika Member Posts: 11
    thanks a lot:)
  • latygo60latygo60 Member Posts: 27
    You're welcome :)
  • monsterpunchmonsterpunch Member Posts: 37
    No no, don't do "You have to drag all the actors that you want on the scene, and inside every actor put a Change attribute". The energy/processing it takes to run is too huge to save all at once. I suggest an Actor called something like "spawner", and after you enter in a certain area, give the spawner an Boolean called "triggered".

    Make a rule in the Spawner that says, if "triggered", Spawn Actor at X location (random[minimum distance far away],[maximum distance]. Use the expression Random and it will make take the first number and the second number and randomized between them. Like in the X in the Spawn Actor box, Random(20,40) and it will be between 20 X pixels to 40 X pixels away from the spawn.
Sign In or Register to comment.