playMaker

Author Topic: How to generate random numbers with a seed? [SOLVED]  (Read 9849 times)

Raika

  • Playmaker Newbie
  • *
  • Posts: 30
How to generate random numbers with a seed? [SOLVED]
« on: November 28, 2017, 05:12:12 AM »
I'm creating multiplayer game with big world. To create objects in game i'm using basic action Random int like that: starting from 0,0 add RanX(2-10) and RanY(0-4 reset Y on object add), when X go 3000, reset X to 0 and add 5 to Y. I don't wanna send this all information thru web because bandwidth limit, I would like to send only seed.

Is it possible to generate numbers in this way using a seed?

« Last Edit: November 30, 2017, 05:41:18 AM by Raika »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: How to generate random numbers with a seed?
« Reply #1 on: November 28, 2017, 05:22:28 PM »
Hi,
I made a action for you to set the seed.

First you would need to do a random int to get a seed nr,

Then you can use the action i made to set the seed (attached below)

I tested it a bit and it seems to work, can you confirm if it works, i can place it on the ecosystem then.
« Last Edit: November 29, 2017, 05:08:15 PM by djaydino »

Raika

  • Playmaker Newbie
  • *
  • Posts: 30
Re: How to generate random numbers with a seed?
« Reply #2 on: November 29, 2017, 03:47:47 AM »
I can see only ecosystem link, can you post once more?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: How to generate random numbers with a seed?
« Reply #3 on: November 29, 2017, 05:07:56 PM »
Hi,
Oops i forgot to add the attachments sorry for that :)

here it is now :)

Raika

  • Playmaker Newbie
  • *
  • Posts: 30
Re: How to generate random numbers with a seed?
« Reply #4 on: November 30, 2017, 05:40:51 AM »
Thanks for help Everything works, if i manage to break something i will contact you on priv.

You can add to description something like that: This action has impact on all FSM but any other random action will pick NEXT number from pool, Call second time to reset.

misterjuly

  • Sr. Member
  • ****
  • Posts: 357
Re: How to generate random numbers with a seed? [SOLVED]
« Reply #5 on: November 17, 2024, 03:58:49 PM »
Hello,

Sorry for posting on an old thread, but I have a question. The action works great and even remembers seeds once the game is powered off, but if I clear player prefs, the same seed results in a different game world. How can I make it so it is consistent for different players playing it regardless of deleting save file. Thanks!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15620
  • Official Playmaker Support
Re: How to generate random numbers with a seed? [SOLVED]
« Reply #6 on: November 19, 2024, 04:13:24 AM »
Hi,

unfortunatly, you can't, unless the values are hardcoded inside your project and built with these.

if the user saves a different value, it will be saved in the playerprefs, and deleting the prefs makes it unrecoverable. you could save data online on a server, then if you have a user management system you can recover data even of the user plays on a new phone or has deleted and reinstalled.

Bye,

Jean

misterjuly

  • Sr. Member
  • ****
  • Posts: 357
Re: How to generate random numbers with a seed? [SOLVED]
« Reply #7 on: December 28, 2024, 07:19:58 PM »
Hello,
I know I said I figured this out, but I started a new project and I can't seem to figure out how to get the seed to visually show on the screen with tiles (I tried to look in the old project, but it wasn't there so I couldn't use it for reference). Could I have step by step instructions of how to do this please? Also, the tiles will be changing during gameplay. If I create a new seed every frame, will it work to have the most up to date version of the tiles?

Thanks!

misterjuly

  • Sr. Member
  • ****
  • Posts: 357
Re: How to generate random numbers with a seed? [SOLVED]
« Reply #8 on: January 08, 2025, 11:45:35 AM »
Bump.