Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Raika on November 28, 2017, 05:12:12 AM

Title: How to generate random numbers with a seed? [SOLVED]
Post by: Raika 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?

Title: Re: How to generate random numbers with a seed?
Post by: djaydino 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 (https://hutonggames.fogbugz.com/default.asp?W1181) then.
Title: Re: How to generate random numbers with a seed?
Post by: Raika on November 29, 2017, 03:47:47 AM
I can see only ecosystem link, can you post once more?
Title: Re: How to generate random numbers with a seed?
Post by: djaydino on November 29, 2017, 05:07:56 PM
Hi,
Oops i forgot to add the attachments sorry for that :)

here it is now :)
Title: Re: How to generate random numbers with a seed?
Post by: Raika 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.
Title: Re: How to generate random numbers with a seed? [SOLVED]
Post by: misterjuly 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!
Title: Re: How to generate random numbers with a seed? [SOLVED]
Post by: jeanfabre 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
Title: Re: How to generate random numbers with a seed? [SOLVED]
Post by: misterjuly 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!
Title: Re: How to generate random numbers with a seed? [SOLVED]
Post by: misterjuly on January 08, 2025, 11:45:35 AM
Bump.