Game Development Community

Player Mounted Head

by Toby W. Allen · in Torque Game Engine · 04/20/2005 (3:48 pm) · 18 replies

Hi,
I've been looking into mounting objects and I can't seem to find what I want - most of it is related to weapons or vehicles.

Aim: I want to mount the main player's head for our probject. So the player loads and you see the whole body; the player script having mounted the head.

I was going for something like this - player.cs
function BasicPlayerShape::onAdd(%this,%obj)
{
%player.mountImage(BasicPlayerHeadShape,0);
}

the head being defines as the following:
datablock PlayerHeadData(BasicPlayerHeadShape)
{
   category = "Head";
   shapeFile = "~/data/shapes/player/head_player.dts";
   emap = false;
}

Would any one be able to help me extend this - I haven't tested this. However, I wanted to know if someone had a nice technique for this sort of problem.

Many thanks,
Toby.

#1
04/20/2005 (5:01 pm)
Umm you do know you appear to be mounting his head in his weapon slot right?
#2
04/20/2005 (5:08 pm)
datablock ShapeBaseImageData(BasicPlayerHeadShape)
{
   category = "Head";
   shapeFile = "~/data/shapes/player/head_player.dts";
   emap = false;
}

function BasicPlayerShape::onAdd(%this,%obj)
{
%head = new BasicPlayerHeadShape;
%this.mountImage(%head,0);
}

The above assumes of course that 0 is the mountPoint for the head and not the mountPoint for the primary weapon.
#3
04/21/2005 (2:38 am)
Thanks - We don't have weapons in our game, so it doesn't matter. Thanks for the help.

Toby.
#4
04/21/2005 (7:24 am)
This is a dumb question but I can't seem to get things workign in ShowTools:
Is this correct:

Head - Mount 0
Body - Mount 0

In Showtool, I load the body and then the head, and put mount 0 of the head on the mount 0 of the body?

What's mountpoint?

Ugg.. Slightly confused now, would it be:
Head - Mount 1
Body - Mount 0

or
Head - Mountpoint
Body - Mount
(That doens't work either)

Toby.
#5
04/21/2005 (8:04 am)
Head - mountPoint
Body - mount0
#6
04/21/2005 (8:23 am)
Ummm Interesting.

I have it setup using
Head - mountPoint
Body - mount0

and yet when I try to link them in ShowTools, it doens't do anything. The models individually show the nodes, but I can't mount them onto each other.

Any common mistakes I could have overlooked?

Toby.
#7
04/21/2005 (8:29 am)
I wish I could help ya more with that friend, I would love to be able to create my characters as pieces and have them mount together, (game idea I had awhile back). But I got frustrated myself and gave up. The code I gave you above, allowed me to mount a head in the characters weapon slot, and thats as far as I ever got, I know it's something with mountPoints but I'm just not sure what.

*update*
Hey this is just a thought, but have you tried mounting the body to the head, instead of the otherway around?
#8
04/21/2005 (8:53 am)
Dreamer,
Thanks for this - I'm just curious as to why I can't even get it mounted in ShowTools, yet I have the stuff ready. It might need to check my exports.
As for the script, I'll get my main scripter on it and check it out, for the moment it's giving me an error, which is odd.

Thanks though!
Tobes.
#9
04/23/2005 (2:11 pm)
In your script above, you have defined the datablock BasicPlayerHeadShape as being of type PlayerHeadData. What sort of datablock is this. If all you want to do is mount the head onto the body, use ShapeBaseImageData(BasicPlayerHeadShape). The problems you are having with your script might be because mountImage() requires a ShapeBaseImageData datablock. The end script would look like this:

datablock ShapeBaseImageData(BasicPlayerHeadShape)
{
   category = "Head";
   shapeFile = "~/data/shapes/player/head_player.dts";
   emap = false;
}

while the code to mount the image is
function BasicPlayerShape::onAdd(%this,%obj)
{
%obj.mountImage(BasicPlayerHeadShape,0);
}

this code has worked for my implementation of this, so I am pretty sure it will work. let me know if you have any problems
#10
04/25/2005 (5:58 am)
Thanks for this - I miscopied the script stuff, while it's not mounting I get this error, which I'm realyl not sure wtf this is caused by:
>>> Advanced script error report.  Line 31.
>>> Some error context, with ## on sides of error halt:
   shapeFile = "~/data/shapes/player/stickyhead.dts";
   emap = false;
}

datablock ##P##layerData(BasicPlayerShape)
{
   renderFirstPerson = false;
   emap = false;
>>> Error report complete.
Toby.
#11
04/25/2005 (9:33 am)
ShapeFile = "~/data/shapes/player/stickyhead.dts";
   emap = false;
}[i][b];[/b][/i]

datablock PlayerData(BasicPlayerShape)
{

};



DataBlocks MUST end with a semi-colon
#12
04/26/2005 (2:14 pm)
Cheers Gonzo, My mistake. It now tried to load it, but I can't get it working still as the console tells me the following:

Object 'PlayerBody' is not a member of the 'GameBaseData' data block class
gds.ninjasticks/server/scripts/game.cs (360): Register object failed for object (null) of class Player.
Set::add: Object "0" doesn't exist
gds.ninjasticks/server/scripts/game.cs (364): Unable to find object: '0' attempting to call function 'setTransform'
gds.ninjasticks/server/scripts/game.cs (365): Unable to find object: '0' attempting to call function 'setShapeName'
gds.ninjasticks/server/scripts/game.cs (368): Unable to find object: '0' attempting to call function 'getEyeTransform'
gds.ninjasticks/server/scripts/game.cs (262): Unable to find function findMissionObject
[onClientEnterGame] Cannot find path 
Mapping string: MissionStart to index: 11
Mapping string: SyncClock to index: 12
Mapping string: SetCounter to index: 13

I somewhat understand what it's trying to do - but I wonder if this might be a model-related issue.

Toby.
#13
04/26/2005 (2:42 pm)
I get that everyonce in while after changing whatever Model I have setup for the ShapeFile in the PlayerBody datablock. For me at least it's because I have a typo in the path to the Shapefile.
#14
04/26/2005 (5:13 pm)
Can I see the function that is giving the errors particularly the line 360 error
#15
05/04/2005 (11:32 am)
I still can't mount that bastard and well here are the files - NS Mounted Heads

I'm not sure what issue is, but it seems to be causing a lot of problems...

Should I have the Eye, Cam, etc.. on the Head or the PlayerBody?

If anyone gets this to work - wippee!
Toby.
#16
05/07/2005 (6:29 am)
Figured out the problem - had to tweak the game.cs a little and use:
function BasicPlayerShape::onAdd(%this,%obj)

{
%head = new BasicPlayerHeadShape;
%this.mountImage(%head,0);
}

Not the obj.... one.

I'll write a little tutorial once I have time.
Toby.
#17
01/13/2008 (2:11 am)
Interesting.
#18
01/13/2008 (7:21 am)
You realize that this thread is about three years old? Bumping it just to say "interesting" is kind of pointless.