Change the player models size in torque script??
by BryceSquared · in Torque 3D Professional · 10/10/2009 (7:27 am) · 23 replies
can it be done? We have a load of files that are way to big or small, and scaling them is breaking quite a few things :), so we have a bit of a problem :)
I am hoping to be able to tell the engine to scale it in the TSShapeConstructor thingy so if anyone knows how, thanks :)
I am hoping to be able to tell the engine to scale it in the TSShapeConstructor thingy so if anyone knows how, thanks :)
#2
10/10/2009 (4:53 pm)
can also add something like this to your datablock for eachfunction ModelData::onAdd(%this,%obj)
{
// Player model scaling
%obj.setScale("0.03 0.03 0.03");
}
#3
10/10/2009 (8:06 pm)
So what I would have to do is in the maleNpc :: defaultplayerdata add a scale field and then in the onAdd set the scale to whatever is in the datablock?
#4
10/10/2009 (8:10 pm)
Using Donalds example, something like this should work but its late so hopefully didn't mess it up.datablock PlayerData(ModelData)
{
...
scaleFactor = "5 5 5";
};
function ModelData::onAdd(%this,%obj)
{
// Player model scaling
%obj.setScale(%this.scaleFactor);
}
#5
10/10/2009 (9:00 pm)
can i make a function that is called every time a playerData is added? so it is called on every type of datablock i have?
#6
I am unable to get the scale to work. In the beta versions of T3D
you had to add the models datablock to datablockExec.cs and also to
init.cs in /scripts/client/
doesn't seem to be anywhere in the init.cs for it now. did that get moved to another location to get the new models datablock to work?
01/14/2010 (5:58 pm)
I had this working a while back but now working with new build.I am unable to get the scale to work. In the beta versions of T3D
you had to add the models datablock to datablockExec.cs and also to
init.cs in /scripts/client/
doesn't seem to be anywhere in the init.cs for it now. did that get moved to another location to get the new models datablock to work?
#7
that works for me in 1.1a
01/14/2010 (7:12 pm)
datablock PlayerData(Villager : DefaultPlayerData)
{
cameraMaxDist = 5;
shapeFile = "art/shapes/actors/villager2.dts";
scale = "0.75 0.75 0.75";
};
function Villager::onAdd(%this, %obj)
{
%obj.scale = %obj.getDatablock().scale;
}that works for me in 1.1a
#8
01/14/2010 (8:32 pm)
mine is almost identical. did you have to call the datablock anywhere other than in datablockExec.cs ?
#9
But don't you need a datacopy of a player/AI type in scripts as well as art, being exec'd from scripts/server/scriptexec.cs for a new player/AI type to be fully functional and not just copy all of it's attributes from player.cs?
01/14/2010 (9:30 pm)
I might be getting the wrong end of the stick here (I haz lurgy, and just spent 45 minutes wondering why a function wasn't working before realising that everytime I set it up I was setting it to off and not to on ...)But don't you need a datacopy of a player/AI type in scripts as well as art, being exec'd from scripts/server/scriptexec.cs for a new player/AI type to be fully functional and not just copy all of it's attributes from player.cs?
#10
My 30 ft tall Gideon Mech-placeholder is more than slightly intimidating, but he doesn't know how to scale his run animation down correctly if he's moving slowly.
01/15/2010 (2:21 pm)
Scaling actually works really well in T3D, even with player objects themselves (not just the model/datablock), though you may find that the player now animates at an inappropriate rate (and uses giant/small weapons -- images scale to the same factor when mounted), so just be prepared to deal w/ that.My 30 ft tall Gideon Mech-placeholder is more than slightly intimidating, but he doesn't know how to scale his run animation down correctly if he's moving slowly.
#11
Try searching scaling animation.
01/15/2010 (7:11 pm)
Konrad Kiss made a resource for that, but I can't remember where...Try searching scaling animation.
#12
I have the datablock called in datablackExec.cs directly after exec("./aiPlayer.cs");
also my datablock is very basic just for the scale currently and is
01/18/2010 (2:22 pm)
can someone expain each step for adding scaling to a player model, or point me to a resource that explains it. I can not seem to get it to read the datablock info. I am missing some call to the datablock or something, just cant seem to figure it out.I have the datablock called in datablackExec.cs directly after exec("./aiPlayer.cs");
also my datablock is very basic just for the scale currently and is
datablock PlayerData(AdultBastlurData: DefaultPlayerData)
{
shapeFile = "art/shapes/actors/adultbastlur/adultBastlurBase.DAE";
// boundingBox = "2.1 2.0 5.4";
scale = "0.4 0.4 0.4";
};
function AdultBastlurData::onAdd(%this, %obj)
{
// Player model scaling
%obj.scale = %obj.getDatablock().scale;
}
PlayerDatasGroup.add(AdultBastlurData);
#13
I'll look into it and see if there were some other steps, but I am sure thats all I did...
EDIT: This is all i did.
01/18/2010 (7:15 pm)
thats all i did o.O, whats going on here?I'll look into it and see if there were some other steps, but I am sure thats all I did...
EDIT: This is all i did.
datablock PlayerData(Villager : DefaultPlayerData)
{
cameraMaxDist = 5;
shapeFile = "art/shapes/actors/villager2.dts";
scale = "0.75 0.75 0.75";
};
function Villager::onAdd(%this, %obj)
{
%obj.scale = %obj.getDatablock().scale;
}
#14
EDIT: ok well that had no effect. also I am using .DAE models so it creates a cached file upon loading the mission. I tried deleting those and letting it reload with the new scale and still no change.
Can anyone think of something I am missing or doing wrong any help would be greatly appreciated
01/18/2010 (8:51 pm)
will try with a biped model and see it it changes anythingEDIT: ok well that had no effect. also I am using .DAE models so it creates a cached file upon loading the mission. I tried deleting those and letting it reload with the new scale and still no change.
Can anyone think of something I am missing or doing wrong any help would be greatly appreciated
#15
In scripts/server/player.cs at the bottom of Armor Datablock methods:
//---------------------------------------------------------------------
// Armor Datablock methods
//----------------------------------------------------------------------
function Armor::onAdd(%this,%obj)
{
%obj.setScale("0.5 0.5 0.5");
}
function Goblin1::onAdd(%this,%obj)
{
%obj.setScale("0.25 0.25 0.25");
}
The top one affects my player model, the second one affects an AI I have called Goblin1
I haven't added other AI yet but will soon to see if it works for all of them.
01/18/2010 (10:18 pm)
Here's what I'm doing and it seems to be working fine...In scripts/server/player.cs at the bottom of Armor Datablock methods:
//---------------------------------------------------------------------
// Armor Datablock methods
//----------------------------------------------------------------------
function Armor::onAdd(%this,%obj)
{
%obj.setScale("0.5 0.5 0.5");
}
function Goblin1::onAdd(%this,%obj)
{
%obj.setScale("0.25 0.25 0.25");
}
The top one affects my player model, the second one affects an AI I have called Goblin1
I haven't added other AI yet but will soon to see if it works for all of them.
#16
01/19/2010 (10:08 am)
I can get that to work but the problem with that is I have one player model that needs to be at one scale and another that needs to be at another. this method sets them all to the same scale. Also have other things I need defined in the datablock for each model for different abilities. Yet my datablock seems to not be getting called properly.
#17
This is probably nothing to do with it -- but -- rename your cached.dts to .dts and change the shapefile from .dae to the new .dts.
Also see my previous post on making sure you have a scripts/server/yourcustomplayer.cs and all of these extra scripts are getting exec'd correctly.
01/19/2010 (12:52 pm)
@DonaldThis is probably nothing to do with it -- but -- rename your cached.dts to .dts and change the shapefile from .dae to the new .dts.
Also see my previous post on making sure you have a scripts/server/yourcustomplayer.cs and all of these extra scripts are getting exec'd correctly.
#18
01/19/2010 (4:02 pm)
what exactly needs to be in the scripts/server/yourcustomplayer.cs in order to get my datablocks to work properly? Is it just a copy of the models datablock or is there more to it?
#19
I thought that in TGE once a Datablock was created, its fields changes are effected only in the server and they won't be transmitted to the clients. Has this changed in T3D, or is my understanding incorrect
01/19/2010 (4:30 pm)
Question: I thought that in TGE once a Datablock was created, its fields changes are effected only in the server and they won't be transmitted to the clients. Has this changed in T3D, or is my understanding incorrect
#20
01/19/2010 (6:33 pm)
If you've built it off Full Template, then these are the Armor and Player functions of player.cs. Which, if you're not altering them, would just be the yourcustomplayer(original demoplayer) functions related to AI (though for some reason I always initiate yourcustomplayerdata::onDamage as well - might have been an issue pre-T3D).
Torque 3D Owner Matt Huston
Atomic Banzai Games
%obj = new Player() { datablock = YourPlayerData; scale = "5 5 5"; }