Creating client side only objects - howto?
by Thomas \"Man of Ice\" Lund · in Torque Game Engine · 08/11/2004 (12:26 am) · 5 replies
I've been trying to develop a 3rd person crosshair that uses an "in world" 3d object as the crosshair.
I reworked the existing guicrosshair code to create the object, place it in the world and it moves nicely with the weapon muzzle.
But I have 2 problems with this that I hope someone can help me with. I tried to search the forums + documentation + code for any clues, but no go. So time to post.
* when I create the object it shows up on all clients
* only the person playing on the server can create the crosshair object
It all makes sense naturally. Only server is allowed to create objects on the fly, object is seen as any other objects and thus shows up in all clients etc.etc.
All my trouble could be solved by creating the object on the client only, but I cant figure out how to do this.
Any hints or clues?
I reworked the existing guicrosshair code to create the object, place it in the world and it moves nicely with the weapon muzzle.
But I have 2 problems with this that I hope someone can help me with. I tried to search the forums + documentation + code for any clues, but no go. So time to post.
* when I create the object it shows up on all clients
* only the person playing on the server can create the crosshair object
It all makes sense naturally. Only server is allowed to create objects on the fly, object is seen as any other objects and thus shows up in all clients etc.etc.
All my trouble could be solved by creating the object on the client only, but I cant figure out how to do this.
Any hints or clues?
#2
Unless other players are going to have interaction with each other's crosshairs (!) I wonder if you didn't go about this the wrong way.
08/11/2004 (5:33 pm)
Here's my question to you: Why create an object? Why not rewrite the behavior of the crosshair to simply move around the screen giving the illusion of being "in the scene"? You could change the size, position, and rotation. Using cast-rays and collision detection (hooks already present in the existing crosshair) you could make it cull around other players, objects, etc.Unless other players are going to have interaction with each other's crosshairs (!) I wonder if you didn't go about this the wrong way.
#3
08/11/2004 (7:09 pm)
You may also what to look at the scopeToClient call. Should be netObject.scopeToClient(clientConnection);
#4
@Bryce: its a matter of taste. The flat crosshair drawn in 2d in the GUI has a very very different feel than an object in the world. There is nothing wrong with thinking out of the box once in a while, but yes - doing the "cast ray from gun to target, transform the end coordinates to the screen coordinates, draw crosshair - its the standard way and the code is already sitting in the existing crosshair resource (basically).
We just didnt want to make a standard game, and its a nice exercise trying to figure out how to create client side objects.
08/11/2004 (11:07 pm)
@Brian and Kevin: Thx a lot. I'll look into this in the weekend@Bryce: its a matter of taste. The flat crosshair drawn in 2d in the GUI has a very very different feel than an object in the world. There is nothing wrong with thinking out of the box once in a while, but yes - doing the "cast ray from gun to target, transform the end coordinates to the screen coordinates, draw crosshair - its the standard way and the code is already sitting in the existing crosshair resource (basically).
We just didnt want to make a standard game, and its a nice exercise trying to figure out how to create client side objects.
#5
08/12/2004 (8:18 am)
Client side objects are tricky but useful.
Associate Kevin Ryan
Top Meadow Inc.
(edit: fixing link)