How do I change my portal spawn location each level?

I followed the first game salad tutorial for beginners and created my "Change Level Portal" and it spawns when I collect the 3 gems. But how do I change the spawn point for the portal each time I complete a level? I'm using the "game functions actor and have as a rule my "gem count" then for DO spawn actor: change level place: in front of actor position 450 by 275. I want those 2 values to change each time I go on a new level so the character doesn't have to go to the same spot every single time.


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

    I'm not sure how helpful I can be since I'm not familiar with that tutorial but you pretty much have two options for changing the spawn position each time:

    1) Use the random function. For example, for the x value, use random(250,450) to choose a value between 250 and 450. Do the same for the y value.

    2) Use a table with preset values. For example, you might have a table with rows like this:

    200 275
    300 275
    400 275

    Then in the spawn actor behavior, use tableCellValue(tableName, random(1,tableRowCount(tableName)),1) for x and tableCellValue(tableName,random(1,tableRowCount(tableName)),2) for y. Obviously, that's quite a bit more complex but tables are a powerful feature of GameSalad.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • jasonrmohanlalljasonrmohanlall Posts: 6Member, PRO

    Thank you!

Sign In or Register to comment.