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

  • jigglybeanjigglybean Member Posts: 1,584

    I dont know if you still need to constrain your attribute to the table.

  • JayJayDJayJayD Member Posts: 48

    @jigglybean‌ Can you tell what you exactly mean? Where should I constrain to the table?

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    You might find this demo I made helpful.

  • JayJayDJayJayD Member Posts: 48

    @tatiang said:
    You might find this demo I made helpful.

    Thank you, I'll study this after work :smile:

  • JayJayDJayJayD Member Posts: 48

    @tatiang‌ Thank you very much :blush: I made some little changes and everything is working now.

Sign In or Register to comment.