Improbable Icon

SpatialOS Forums

ProcGen

Hi!

I’m currently finishing a procedural generation system that spawn objects at the same place on both client and worker using a PRNG seeded from a grid.

It save bandwidth and cpu as it spawn/despawn objects around the player.

My problem is that I need each objects to have a unique seed for some other system. Using a grid to seed a PRNG give unique values only for that grid’s cell and I don’t want to use entities unless it’s necessary.

Any ideas?

Thanks!

Hi @SionoiS

When you say that you don’t want to use entities unless necessary, what are you referring to? If you’re spawning these objects on the worker as well then aren’t you already creating entities for them? Could you give a little more context please?

1 Like

Hi,

In my game, i’m spawning asteroids, a lot of them and so I thought that having a SpatialOS entity for each one was overkill. (maybe not?)

Theses only have collisions so around ships is the only place they are needed.

Also, I think I solve my problem by using the dot product of the asteroid position vector with a fixed random one.

edit: What is the cost of having millions of spatialos entities (asteroids) VS only gameobjects local to workers?

Hi @SionoiS

I think I understand what you’re going for. Absolutely, if you don’t need to replicate these objects and can instead spawn them deterministically in identical places on the client and server workers then you would save a lot of network bandwidth by doing this. You were looking for a means to derive a new seed for each, but it sounds like you’ve found an elegant solution for that already.

With regards to the cost of many entities versus only gameobjects local to a worker; those SpatialOS entities will entail a large network overhead and additional processing whilst the gameobjects will require processing of their own on the worker. The resource cost of the gameobjects would be a static value whether they have matching entities or not, however, so avoiding unnecessary use of entities for them would be a win in terms of network optimization. The exact saving you’d get would be entirely dependent on their complexity and other implementation details.

I hope that helps answer your question.

1 Like