Spawning random number of Actor at preset position with Table

JayJayDJayJayD Member Posts: 48
edited July 2014 in Working with GS (Mac)

Hey Guy's,

I have an little Problem, which may be answered in another Thread. After several hours of trying I decided to post my problem here :)

I have a table with 4 different X positions in it: 40, 120, 200 and 280.
And I have an Actor which should randomly spawn 1 to 3 times at the same time at the positions above. But the positions shouldn't be used twice.

My plan at this moment is to delete the row after spawning so that the Actor can't use the position again.

Here my logic:

Timer every 3 Seconds

  • Copy Master Table to TB_Laser_Data

  • Change attribute --> self.LasersToSpawn = random(1,3)

  • Loop --> while ( LasersSpawned < LasersToSpawn)

    • change attribute --> self.Laser Row = random(1,tableRowCount( game.Tb_Laser_Data ))
    • Spawn Actor --> Laser - Position X: tableCellValue( game.Tb_Laser_Data , self.Laser Row ,1) Y = 100
    • Add Remove Row --> at Index : Laser Row
    • Change attribute --> LasersSpawned to LasersSpawned + 1

In the latest attempts i tried it with a Loop, but im pretty sure that im using it in the wrong way. But I also tried several other ways for example with a timer. But it seems that two timers nested don't work properly.

The Spawning isn't the biggest problem. The Lasers are spawned 3 times but at exactly the same position.

Maybe somebody is able to help me.
Hope you understand my English :)

Kind Regards,
Justin

Comments

Sign In or Register to comment.