About Store Forum Documentation Contact
Donations:
140$/mo



Post Reply 
how to create an object when out of range?
Author Message
yvanvds Offline
Member

Post: #1
how to create an object when out of range?
Hello again.

What I'm trying to do (in a multiplayer environment) is this: a player creates an object and the object should appear to other players as well. I can use Game::World.objCreateNear(), but this way the object does not get created when a player is out of range.

I understand that objects in my Game::ObjMemx<Item> container are added to the world when the player comes close enough, but I can't add one with New() since I should use the World manager for this.

So I cannot use Items.new() because it's private for ObjMemx, and I cannot use objCreate() because it fails if objects are out of range. Is there a way to add objects when their initial position is out of range?

Regards,

yvan
03-05-2011 09:28 PM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #2
RE: how to create an object when out of range?
According to Header Browser, objCreate() succeeds if the object is out of range, however no pointer to the object is returned (since it is out of range).
(This post was last modified: 03-05-2011 09:53 PM by Driklyn.)
03-05-2011 09:53 PM
Find all posts by this user Quote this message in a reply
Dynad Offline
Member

Post: #3
RE: how to create an object when out of range?
Its not the best option to save all data on the clients when its not in range.. its just a waste of bandwidth.. You should create your own containers so you can decide when a item gets synchronized with the server.. The server tells the client when to create new/update/delete a object.. you can use the enums for that..

The best option is to make 2 classes: 1 render class and 1 object class.. that way you can hide your meshes without turning them all off or no need for some weird render code hack.. not only that i like to have the rendering and netcode separated.. the engine doesn't need to know whats happening.. rendering only is enough wink


~Dynad

There is always evil somewhere, you just have to look for it properly.
03-05-2011 10:04 PM
Visit this user's website Find all posts by this user Quote this message in a reply
yvanvds Offline
Member

Post: #4
RE: how to create an object when out of range?
Thanks for your thoughts, Driklyn and Dynad.

Seems I have two options:
1. use ObjCreate() and add a special parameter to find the object in the container. (I have to set some custom parameters afterwards.)

2. make a separate object class and see when the player position comes into range, then add it to the Item container.

@Dynad: In my game, other players might be pushing around objects a lot. So when I do not make all objects known to all players, I'll constantly have to check distance between all objects and all players to see when to inject an object to a client. Also, my objects emit sound, which can be heard from a lot further if few other sounds are playing (using a logarithmic rolloff system). Since sound movement is audible only when the change is more than about 8 degrees in a surround setting, I plan to correlate position updates for distant objects to that, hoping to minimize network traffic that way.

But yes, separating object and render classes might be usefull anyway. Seems I'll have to rethink this once again :-)
03-05-2011 10:29 PM
Find all posts by this user Quote this message in a reply
menajev Offline
Member

Post: #5
RE: how to create an object when out of range?
You can keep whole map loaded.
Code:
Game::World.init(Game::WORLD_FULL);
(This post was last modified: 03-06-2011 10:34 PM by menajev.)
03-06-2011 10:34 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #6
RE: how to create an object when out of range?
In option 1 you can set custom parameters in game::obj::create, not only after creating the object
03-07-2011 07:50 AM
Find all posts by this user Quote this message in a reply
Post Reply