Random non-repeating spawn points?

CowuniverseCowuniverse Member, PRO Posts: 97

I looked up how to make random, specified spawn points and got that down with tables, but I have a coin that spawns twice in the same location and I don't want that to happen. Instead I want it to always go to a random point other than the on it was just at. Thank you for the help.

Best Answer

  • HopscotchHopscotch Posts: 2,782
    edited July 2015 Accepted Answer

    @Cowuniverse

    ok, soo, let us rather use math to make a non repeating random list of numbers:

    mod( LastNumber-1+random(1,TotalRange-1) , 3 ) +1

    First create a new self.attribute, NumberRange

    Then add tis behavior

    Change Attribute self.NumberRange = TableColCount(game.coin points)

    then, where you change game.coin spawn do this

    Change Attribute game.coin spawn = mod(game.coin spawn-1+random(1,self.NumberRange-1))+1

    The rest is the same.

Answers

  • HopscotchHopscotch Member, PRO Posts: 2,782

    @Cowuniverse, this is a forum for game developers, not clairvoyants. :)

    You will need to give more info as to how you approach it and what is not working.

    You say you looked up and use tables for the random spawn points. Then you should be good.

    But since it is not working for you, we have no idea what you did, thus no idea what to suggest.

    Post a screenshot of your rules maybe.

  • CowuniverseCowuniverse Member, PRO Posts: 97

    @Hopscotch

    That is the table and the other screenshot is in the behaviors in the coin. I'm trying to make the coin not spawn at the same point twice, but at one of the other 4 points it isn't already on.

  • HopscotchHopscotch Member, PRO Posts: 2,782

    @Cowuniverse

    Please show me the expressions in the "Spawn Actor" behavior.

    Do you store the position the last coin was on? Then you could just check that "game.coin spawn" is not equal to the last spawn position.

  • CowuniverseCowuniverse Member, PRO Posts: 97

    @Hopscotch said:
    Cowuniverse

    Please show me the expressions in the "Spawn Actor" behavior.

    Do you store the position the last coin was on? Then you could just check that "game.coin spawn" is not equal to the last spawn position.

    how would you check? that is wasn't at the last position?

  • CowuniverseCowuniverse Member, PRO Posts: 97

  • CowuniverseCowuniverse Member, PRO Posts: 97

    @Hopscotch said:
    Cowuniverse

    ok, soo, let us rather use math to make a non repeating random list of numbers:

    mod( LastNumber-1+random(1,TotalRange-1) , 3 ) +1

    where do I put this part?

  • CowuniverseCowuniverse Member, PRO Posts: 97

    @Hopscotch Never mind I got it to work. Thank you very much!

  • HopscotchHopscotch Member, PRO Posts: 2,782

    @Cowuniverse, my pleasure, glad it helped. :)

Sign In or Register to comment.