Game Development Community

PLayer Datablock

by Kirchgessner · in Torque Game Engine · 01/26/2006 (8:34 am) · 3 replies

I need help with this, my player datablock is fine, but what i would like to know is how to make the datablock spawn in game on the clientside.

The reason for this is i want to have a player selection and each player have thier own character and not have the server player make everyone elses datablock the same as his. And i want to take away the observer camera.

I'm trying not to sound confusing, ok i want to get around this

--game.cs--
.
..
%player = new Player(){
datablock = PLayerBody;
client = %this; <<<<<------------- This is what i don't want
}
.
..

there that seems more understandable.

#1
01/26/2006 (8:41 am)
It sounds as if what you are looking for is the ability for players to select which type of player they want, and have it different from what others (may) select.

There are several resources to to this--I suggest searching for "player selection" as a start.

Here is just one example.

FYI, datablocks don't actually spawn...they are simply reference information for Player (and other classes as well) objects to use to define static information that doesn't change during gameplay.

In your line above where you say "This is what I don't want", actually that line is unrelated to which datablock is being used--it simply aligns a variable on the server (which is required) to make sure that we keep track of the %client handle for that particular %player object. I think you meant to put the line one more line up, but that's just a guess!
#2
01/26/2006 (8:50 am)
Stephen:
Thanks for your input, i'll have to look at the team spawning thing when i get home.

I did know that the datablocks didn't spawn, but the client tag inside the new player(), i didn't know that, that was a variable to keep the track of the clients, i thought it was a variable to create everybody with the same datablock.
#3
01/26/2006 (9:08 am)
The 'datablock = PlayerBody' is the actual line that is making all of your players the same. In a nutshell, that resource (as well as others) are simply interfaces to allow the player to choose which datablock is going to be used in that particular line.

The reason the "client = %this" line is there is because Torque is a very event driven system, as well as very much object oriented when it comes to access to various functionality. In this specific case, there are times when you need to find out which client (player) is actually the one "connected" to a particular player object in the game. In these cases, normally all you have access to is the player object itself, so we are storing a handle to the client that controls this player at the script level for easy access to that client's information.

Very simple use example, not really something you'll see, but to illustrate the point:

Let's say that during simulation processing, a player object gets attacked. In script you could use one of the callbacks that is made available (such as ::onDamage) to send a message to the client (via commandToClient) saying that they were attacked. Without this persistent field being populated when we create the player object, we would require additional effort to know which client to send the message to.