Player Selection
by Louis Dufresne · in Artist Corner · 01/09/2004 (8:23 am) · 85 replies
I have a GUI that allows you to select from 4 players. I have all the DTS's for each model and im using the Orc's animations at this time for each player model. Ive added to prefs.cs -> prefs::player::character = ""
In the selection GUI I just change this value to correspond to the player I want. Also I have a separate CS file for each player, all of which are included in the game.cs. Now im just not sure on how or where to tell the game, in script, which player model to load when the game starts. Anyone know where this is? Or how its done?
In the selection GUI I just change this value to correspond to the player I want. Also I have a separate CS file for each player, all of which are included in the game.cs. Now im just not sure on how or where to tell the game, in script, which player model to load when the game starts. Anyone know where this is? Or how its done?
About the author
#62
08/26/2006 (1:07 pm)
This would be totally great, Will keep this bookmarked for watching.
#63
I got it to work :)
Now, if I can only remember how I did it. If I get a chance this week, I will write out a tutorial. I'm by no means a seasoned Torque programmer, but I felt that rush when I finally got it to work...
[...dances off to the coffee shop to celebrate...]
08/27/2006 (8:17 am)
Woohoo!I got it to work :)
Now, if I can only remember how I did it. If I get a chance this week, I will write out a tutorial. I'm by no means a seasoned Torque programmer, but I felt that rush when I finally got it to work...
[...dances off to the coffee shop to celebrate...]
#64
08/27/2006 (3:01 pm)
Great news, looking forward to the resource :)
#65
08/28/2006 (10:45 pm)
Hi gang, I wrote this today after dinner. Please have a look and try it out. If all is cool, I will submit it as a resource. Here's the initial tutorial for basic player selection. It has pictures too!
#66
08/29/2006 (12:37 am)
Quickly scanned through it. Interesting method. Good job. I will be uploading my resource tomorrow, which is different from yours. Thanx for sharing.
#67
James (BurNinG) Laker I look forward to see your method.
Thanks to both you for sharing.
08/29/2006 (8:45 am)
James I try to download the support files but get error. I was looking over the tutorial there a much easy way than create a whole new datablock PlayerData(PlayerBody2). I happen catch Mike Rowley code in the early stage. I think it was call model choice but I must have been spacing or something. I have been watch this topic and until today the light bulb turn on. I modify his code a little. I will try later see if I can download support files. James (BurNinG) Laker I look forward to see your method.
Thanks to both you for sharing.
#68
oops!
Sorry 'bout that. The download works now:)
Regarding this tutorial, it's my first set of scripts in which I actually figured out by using the gazillion references in this forum and then hashing out my own set. So far, it is working ok. I was surprised this function didn't come as part of the starter.fps set. That being said tho, there is already a lot of value that GG has given to date.
[edit: added a space after download]
08/29/2006 (8:54 am)
Michael,oops!
Sorry 'bout that. The download works now:)
Regarding this tutorial, it's my first set of scripts in which I actually figured out by using the gazillion references in this forum and then hashing out my own set. So far, it is working ok. I was surprised this function didn't come as part of the starter.fps set. That being said tho, there is already a lot of value that GG has given to date.
[edit: added a space after download]
#69
08/29/2006 (9:04 am)
Yes I would agreed with you there. You did outstanding job with tutorial. Thanks for download. I look for try it out.
#70
That code is called in Game.cs "commandToClient(%this, 'startSpawn');" and calls the datablock later in the switch statement.
What I forgot to add to the above code was my player.cs files. In server/scripts/ I've added another folder called "Player" and in it, I added the player.cs files for each of my avatars. I have the original called player.cs, one named male.cs and one named female.cs, and another seperate script called "execAll.cs" that just execs the different player.cs files. In them, I changed the datablocks for the player, and point to the avatar.
In male.cs, I have changed:
Sorry for the confusion.
08/29/2006 (6:43 pm)
Quoted by James TadeoQuote:Ok, I do have a question relating to this part:I apologise for missing this.
//===========================================================================
//added this function for model selection
//===========================================================================
function clientCmdstartSpawn() {
%spawnModel = "MaleModel";
//set your default
if ($pref::model::female)
%spawnModel = "FemaleModel";
//you could check $pref::model::male [else if...] here, but since it's the default, no need to
commandToServer('spawnPlayer', %spawnModel);
}
//----------------------------------------------------------------------------
I've saved it and named it avatarChoice.cs. What exactly does it do? Does it get called from another part of code that isn't shown?
As well, how does this code correlate to the .dts files of my models. For example, I have an orc and I have a male avatar. I currently have them residing in the default Starter FPS Kit locations. Namely, in the /data/shapes/player directory. I would like to be able to choose between the orc or the male avatar.
I'm wondering how exactly are the different .dts files are being called based on your examples.
That code is called in Game.cs "commandToClient(%this, 'startSpawn');" and calls the datablock later in the switch statement.
What I forgot to add to the above code was my player.cs files. In server/scripts/ I've added another folder called "Player" and in it, I added the player.cs files for each of my avatars. I have the original called player.cs, one named male.cs and one named female.cs, and another seperate script called "execAll.cs" that just execs the different player.cs files. In them, I changed the datablocks for the player, and point to the avatar.
In male.cs, I have changed:
// Load dts shapes and merge animations
exec("~/data/shapes/player/Adam/player.cs");
//Further down the file:
datablock PlayerData(AdamBody)
{
renderFirstPerson = false;
emap = true;
className = Armor;
shapeFile = "~/data/shapes/player/Adam/player.dts";
cameraMaxDist = 3;
computeCRC = true;I did this for the female avatar as wellSorry for the confusion.
#71
Thanks for that bit. In working with datablocks, I found that fields can be inherited from another datablock like this:
It's much cleaner than the example I put up...
*sigh* so much to learn...
...sip...
08/30/2006 (5:21 pm)
Hey Mike,Thanks for that bit. In working with datablocks, I found that fields can be inherited from another datablock like this:
datablock PlayerData(AdamBody: AnotherBody)
{
//all fields are inherited from AdamBody
//shapefile is overridden
shapeFile = "~/data/shapes/player/AnotherBody/AnotherBody.dts";
}It's much cleaner than the example I put up...
*sigh* so much to learn...
...sip...
#72
signed:
still learning. :-D
08/30/2006 (5:43 pm)
LOL. I had originally tried it that way, but was having problems when attempting to connect across the net. I found out later, it wasn't my code at all. I had goofed the install of the avatars. :blush:signed:
still learning. :-D
#73
A side note , If anyone wants to is they can keep there player character files neater than having them all in one player file.
With in the data/shape/player file create your seperate files for instance orc , orc1 , orc2 and so on depending on your players.
Keep the generic files that are used by all the players such as the spash and foot print image out in the main directory of the player file folder.
Now take the player.cs file out of the orc folder which tells you all the animations and add the rest of your characters animations to it as well if they have different animations.
Place this player.cs file back into the orignal data/shapes/player file folder. And you can delete the one in the orc files.
Now in the starter.fps/server/scripts/player.cs file you can leave the top section of the code original
This will allow your player selection to still read the player.cs file in the player menu and pick up all the players animations for the chracters you chose if they have different animations.
09/01/2006 (1:38 pm)
This also works on the latest version of TGE if anyone cares, Or maybe it was mentioned LOL I scim through stuff and may have missed it lol, I thought i read here it was based on 1.3 lol Anyhow........A side note , If anyone wants to is they can keep there player character files neater than having them all in one player file.
With in the data/shape/player file create your seperate files for instance orc , orc1 , orc2 and so on depending on your players.
Keep the generic files that are used by all the players such as the spash and foot print image out in the main directory of the player file folder.
Now take the player.cs file out of the orc folder which tells you all the animations and add the rest of your characters animations to it as well if they have different animations.
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
datablock TSShapeConstructor(PlayerDts)
{
baseShape = "./orc/player.dts";
sequence0 = "./orc/player_root.dsq root";
sequence1 = "./orc/player_forward.dsq run";
sequence2 = "./orc/player_back.dsq back";
sequence3 = "./orc/player_side.dsq side";
sequence4 = "./orc/player_lookde.dsq look";
};
datablock TSShapeConstructor(orc1Dts)
{
baseShape = "./orc1/orc1.dts";
sequence0 = "./orc1/player_root.dsq root";
sequence1 = "./orc1/player_forward.dsq run";
sequence2 = "./orc1/player_back.dsq back";
sequence3 = "./orc1/player_sit.dsq side";
sequence4 = "./orc1/player_kneel.dsq look";
};
datablock TSShapeConstructor(orc2Dts)
{
baseShape = "./orc2/orc1.dts";
sequence0 = "./orc2/player_root.dsq root";
sequence1 = "./orc2/player_forward.dsq run";
sequence2 = "./orc2/player_back.dsq back";
sequence3 = "./orc2/player_crawl.dsq side";
sequence4 = "./orc2/player_swim.dsq look";
};Place this player.cs file back into the orignal data/shapes/player file folder. And you can delete the one in the orc files.
Now in the starter.fps/server/scripts/player.cs file you can leave the top section of the code original
// Load dts shapes and merge animations
exec("~/data/shapes/player/player.cs");This will allow your player selection to still read the player.cs file in the player menu and pick up all the players animations for the chracters you chose if they have different animations.
#74
09/01/2006 (2:40 pm)
Next step is to get an avatar to appear by the player so you can see what you want and maybe a armoury where you can also choose weapons you want your character to use before going into the server :)
#75
09/01/2006 (3:29 pm)
That what I am working on now.
#76
re:"Next step is to get an avatar to appear by the player so you can see what you want and maybe a armoury where you can also choose weapons you want your character to use before going into the server :)"
I have a version chooses weapons from a drop down menu. If anyone wants it, I will post it for download. Right now, I would like to know how to have the player's choice show a small preview when they select a weapon or different player avatar.
Oh and btw, I had to update my draft Torque tutorial . It seems I missed to point out the function GameConnection::createPlayer(%this, %spawnPoint) in the last bit. Sorry gang. It was in the download files but wasn't included in the Web version. At the time it was late and...aw nuts, ok, I goofed...lol...
...sip....
09/01/2006 (11:34 pm)
Allan Stewart,re:"Next step is to get an avatar to appear by the player so you can see what you want and maybe a armoury where you can also choose weapons you want your character to use before going into the server :)"
I have a version chooses weapons from a drop down menu. If anyone wants it, I will post it for download. Right now, I would like to know how to have the player's choice show a small preview when they select a weapon or different player avatar.
Oh and btw, I had to update my draft Torque tutorial . It seems I missed to point out the function GameConnection::createPlayer(%this, %spawnPoint) in the last bit. Sorry gang. It was in the download files but wasn't included in the Web version. At the time it was late and...aw nuts, ok, I goofed...lol...
...sip....
#77
09/04/2006 (3:26 pm)
@J Tadeo... What ur mail addy? Or please contact me...
#78
I sent you my addy....
...tonight, I am gonna look at player selection with a preview. I saw some resources here already but I don't really know how reliable the tutorials are. The only way to find out is to try them out...
09/04/2006 (4:22 pm)
@J Laker,I sent you my addy....
...tonight, I am gonna look at player selection with a preview. I saw some resources here already but I don't really know how reliable the tutorials are. The only way to find out is to try them out...
#79
09/04/2006 (4:54 pm)
Very good tutorial!! Great layout and easy to read and follow!!
#80
Above: I used the files from this resource by Vince_Smurf and Loonatik. For the example above, I used the extended guiObjectView by Xavier.
I had a look at this tutorial:
Player Selection by Chris \"C2\" Byers.
...using the guiObjectView, but noticed the interface was very plain and not animated. There are actually two versions that I found related to guiObjectView. The original one was extended by Xavier "eXoDuS" Amado. You can see Xavier's resource here.
The original guiObjectView was written by these guys Vinci_Smurf and Loonatik. Their handy work can found at:guiObjectView - Mountable Animated DTS Viewer <--this is the original one
I tried out their gui and used their files as a basis for my tutorial using the guiObjectView by Xavier but the original files did not work with *my* files. I would imagine the original compilation would work fine.
The first tutorial cited (by Chris) did not have a weapons mount, even though it uses the more recent guiObjectView extended by Xavier. In comparing the files, I noticed that the orignal guiObjectView had five parameters for mountObject, and the new one by Xavier had six! What's cool about Xavier's version is that you can continually mount objects like pancakes. As it would appear to me, it makes for a near limitless venue for expanding player selections and choices.
I will start a first draft of a complete tutorial this evening and post it.
...sip...
09/04/2006 (5:53 pm)
Above: I used the files from this resource by Vince_Smurf and Loonatik. For the example above, I used the extended guiObjectView by Xavier.I had a look at this tutorial:
Player Selection by Chris \"C2\" Byers.
...using the guiObjectView, but noticed the interface was very plain and not animated. There are actually two versions that I found related to guiObjectView. The original one was extended by Xavier "eXoDuS" Amado. You can see Xavier's resource here.
The original guiObjectView was written by these guys Vinci_Smurf and Loonatik. Their handy work can found at:guiObjectView - Mountable Animated DTS Viewer <--this is the original one
I tried out their gui and used their files as a basis for my tutorial using the guiObjectView by Xavier but the original files did not work with *my* files. I would imagine the original compilation would work fine.
The first tutorial cited (by Chris) did not have a weapons mount, even though it uses the more recent guiObjectView extended by Xavier. In comparing the files, I noticed that the orignal guiObjectView had five parameters for mountObject, and the new one by Xavier had six! What's cool about Xavier's version is that you can continually mount objects like pancakes. As it would appear to me, it makes for a near limitless venue for expanding player selections and choices.
I will start a first draft of a complete tutorial this evening and post it.
...sip...
Torque Owner James Laker (BurNinG)