Game Development Community

Weapon Image

by genomegames · in Torque 3D Professional · 10/01/2012 (5:43 am) · 4 replies

Hello everybody!
In our game I have one weapon image: HumGunImage
Many weapons inherit property values of this
All of these values are the same; Yes, I know: each object of a datablock is the same
I wanna make different values to different objects
ShapeBaseImageData has not a parent class, and I can not add members to this
Does anybody know what can I make different objects of one image?

#1
10/01/2012 (3:12 pm)
If I understand correctly what you would like to do, then you can use TorqueScript's ability to copy from a source when creating an object. If HumGunImage has all of the default properties that you want to use as a base, then create your other weapons like this:

datablock ShapeBaseImageData(MyWeapon2 : HumGunImage)
{
   ...
}

datablock ShapeBaseImageData(MyWeapon3 : HumGunImage)
{
   ...
}

I don't think there are any examples of this in the templates, but you can see this in action for the DemoPlayer datablock where it copies everything from DefaultPlayerData and only adds the shootingDelay field. This is in art/datablocks/aiPlayer.cs in the Full template.

I hope that helps.

- Dave
#2
10/02/2012 (12:21 am)
Thank you Dave
I don't wanna create many weapon images
I wanna have single image
#3
10/02/2012 (1:00 am)
What sorts of values do you want to be different for each 'object'?

I put 'object' in quotation marks because ShapeBaseImages do not actually exist as separate objects. They only exist when mounted on a ShapeBase. So when you call mountImage(%image, %slot), you are telling a ShapeBase object (like the Player) to display an image that looks like the datablock %image.
#4
10/02/2012 (1:27 am)
I've found the solution
I store unique values in player class members
It works well for me