Ghost Object implementation - Need clarification
by elvince · in Torque 3D Professional · 02/10/2011 (11:26 pm) · 5 replies
Hi,
I need some help to understand properly how I should implement a ghost object for a define scope of player.
Here is my case:
1/ I have a object, let's say a weapon class that contains characteristics like datablock, durability, TagName...
2/ I want this object to be sent only to the player that owns it
3/ I want to be able to send the object onDemand to other player.
What should I do to implement this?
As of today, I use a simobject as base class and it's working well locally. Now, I'm looking for the network part, I thought about using netevent to send the information to client connection I want, but I'm not sure this is the right way to do it in my case.
I look further, and it seems that I should use a netObject (or maybe gamebase) as base class. In this case, I don't know how to scope properly my object (is it scopeLocal && Ghostable?) and manage onDemand sending to specific player (I can manage this by Script if I can't "update" the scope).
I hope someone can help me :D
Thanks,
I need some help to understand properly how I should implement a ghost object for a define scope of player.
Here is my case:
1/ I have a object, let's say a weapon class that contains characteristics like datablock, durability, TagName...
2/ I want this object to be sent only to the player that owns it
3/ I want to be able to send the object onDemand to other player.
What should I do to implement this?
As of today, I use a simobject as base class and it's working well locally. Now, I'm looking for the network part, I thought about using netevent to send the information to client connection I want, but I'm not sure this is the right way to do it in my case.
I look further, and it seems that I should use a netObject (or maybe gamebase) as base class. In this case, I don't know how to scope properly my object (is it scopeLocal && Ghostable?) and manage onDemand sending to specific player (I can manage this by Script if I can't "update" the scope).
I hope someone can help me :D
Thanks,
About the author
Recent Threads
#2
I will dig into the code and try to understand how I can have manual scoping.
I have question in mind like:
When an object is ghosted and become out of scope, does the object is destroyed on client side or is just not updates anymore?
In my understanding netevent are here to send data out of the regular maskbit system. You can use it to send update that are driven by a script without having a new maskbit. This is useful for player where bits are counted.
I will start digging from netobject or gamebase and see where it leads.
In the meantime If you have few minutes for other guidance I will apreciate!
Thanks,
02/11/2011 (2:33 pm)
Thanks to have take some time. I will dig into the code and try to understand how I can have manual scoping.
I have question in mind like:
When an object is ghosted and become out of scope, does the object is destroyed on client side or is just not updates anymore?
In my understanding netevent are here to send data out of the regular maskbit system. You can use it to send update that are driven by a script without having a new maskbit. This is useful for player where bits are counted.
I will start digging from netobject or gamebase and see where it leads.
In the meantime If you have few minutes for other guidance I will apreciate!
Thanks,
#3
When an object is ghosted and it is out of scope,its ghost is deleted.
When it comes back into scope,its ghost is re-created.And this happens all the time.
If you have to create an object-to-object dependence,you could use SimObjectPtr.At least you can use Player::onCameraScopeQuery() and directly drag your object into scope there.
02/12/2011 (4:33 am)
Well, I think this is what happens:When an object is ghosted and it is out of scope,its ghost is deleted.
When it comes back into scope,its ghost is re-created.And this happens all the time.
If you have to create an object-to-object dependence,you could use SimObjectPtr.At least you can use Player::onCameraScopeQuery() and directly drag your object into scope there.
#4
And the way ghost is working is my understanding also (by reading comment in netobject source code)
02/12/2011 (8:17 am)
I will look at the camera query. I read in the doc that where the scope is manage. And the way ghost is working is my understanding also (by reading comment in netobject source code)
#5
you are right the function is: scopeToClient on netobject.
so if I create netobject, I can manually ghost them with this!
with a limitation of 4096 ghosts on the client by default.
02/12/2011 (9:01 am)
@ted,you are right the function is: scopeToClient on netobject.
so if I create netobject, I can manually ghost them with this!
with a limitation of 4096 ghosts on the client by default.
Torque 3D Owner Ted Southard
So I think you should experiment with manual calls to turn that scoping on and off. I'm not sure if it's netObject or netEvent, but I'm sort of pressed for time this morning or else I'd go dig around for you. You could also play with a class like AIPlayer and extend it to add those methods, connect two players, spawn the bot and then toggle its scoping between the two (and for both).
Probably not as detailed as you might have liked, but I hope it helps anyway!