character programming. help me
by David · in Game Design and Creative Issues · 10/25/2012 (10:51 am) · 20 replies
I can design and animated a character, i need to know where to learn how to program my character from scratch and with a controller. any help will be greatly appreciated
About the author
-@_@- i like math. learning on my own to be a video game programmer
#2
10/25/2012 (11:42 am)
torque 3d
#3
Alot of the functionality is already there, crouching, sprinting, jumping, pick stuff up, mount vehicles, shoot weapons.. What do you need?
Or do you just want to know how to load up your model as a player in the game?
10/25/2012 (11:46 am)
Do you want to program the character from the ground up?Alot of the functionality is already there, crouching, sprinting, jumping, pick stuff up, mount vehicles, shoot weapons.. What do you need?
Or do you just want to know how to load up your model as a player in the game?
#4
i can get my model in torque, i just cant control it
10/25/2012 (11:59 am)
i looked at the code for the default solider but i dont understand it.i can get my model in torque, i just cant control it
#5
Now, to actually get some animations you will need to supply a script file in the same folder as your model. This file should have 2 things, a singleton TSShapeConstructor and a function onLoad. like this:
The script file for the model can also be generated by the shape editor by simply loading up your model and editing your shape which might be easier to do.
10/25/2012 (12:08 pm)
To change the model, simply change the shapeFile value in the PlayerData datablock. This is what I changed it to for my specific model:shapeFile = "art/shapes/actors/elementalist/FemElementalist.dts";Try doing that and see if you can use your movement keys to move the player.
Now, to actually get some animations you will need to supply a script file in the same folder as your model. This file should have 2 things, a singleton TSShapeConstructor and a function onLoad. like this:
singleton TSShapeConstructor(Felem_de)
{
baseShape = "./FemElementalist.dae";
loadLights = "0";
unit = "1";
upAxis = "DEFAULT";
lodType = "TrailingNumber";
ignoreNodeScale = "0";
adjustCenter = "0";
adjustFloor = "0";
forceUpdateMaterials = "0";
};
function Felem_de::onLoad(%this)
{
%this.addSequence("./Anims/FemElementalist_Walk.dsq", "Back", "0", "-1", "1", "0");
%this.addSequence("./Anims/FemElementalist_Dying.dsq", "Death1", "0", "-1", "1", "0");
%this.addSequence("./Anims/FemElementalist_JumoRun.dsq", "RunJump", "0", "-1", "1", "0");
%this.addSequence("./Anims/FemElementalist_CombatModeA.dae", "Root", "0", "-1", "1", "0");
%this.addSequence("./Anims/FemElementalist_Run.dsq", "Run", "0", "-1", "1", "0");
%this.addSequence("./Anims/FemElementalist_DodgeToLeft.dsq", "Side", "0", "-1", "1", "0");
%this.setSequenceCyclic("Root", "1");
%this.setSequenceCyclic("Side", "1");
%this.setSequenceGroundSpeed("Back", "0 -3.6 0", "0 0 0");
%this.setSequenceGroundSpeed("Run", "0 5 0", "0 0 0");
%this.setSequenceGroundSpeed("Side", "-3.6 0 0", "0 0 0");
}There is diferent animation name that automagically is called when certain actions are called on the player (like run or root) I don't have a complete list of them here but you should be able to find them in the shape editor.The script file for the model can also be generated by the shape editor by simply loading up your model and editing your shape which might be easier to do.
#7
10/25/2012 (12:26 pm)
alright! thanks man, ill try wat you said asap
#9
10/25/2012 (1:24 pm)
Ahh there is an AddPlayer tutorial aswell? Excellent Dan! Sorry for not pointing that out Dominic, that tutorial will probably help you more than I did :)
#10
10/25/2012 (2:44 pm)
Lukas, the character is derived from the shape primarily, so that was a good entry point in my opinion. But hey, I'm an artist.
#12
10/25/2012 (10:30 pm)
wait i mean how do i program like the arrow keys and the controllers
#13
10/25/2012 (10:32 pm)
wait i mean how do i program like the arrow keys and the controllers
#14
if u r a programmer then look into bind()'s description from script manual.
also on "action map"
then do a look into \scripts\client\default.bind.cs
specially on these:
[code]
moveMap.bind( keyboard, a, moveleft );
moveMap.bind( keyboard, d, moveright );
moveMap.bind( keyboard, left, moveleft );
moveMap.bind( keyboard, right, moveright );
moveMap.bind( keyboard, w, moveforward );
moveMap.bind( keyboard, s, movebackward );
moveMap.bind( keyboard, up, moveforward );
moveMap.bind( keyboard, down, movebackward );
moveMap.bind( keyboard, e, moveup );
moveMap.bind( keyboard, c, movedown );
moveMap.bind( keyboard, space, jump );
moveMap.bind( mouse, xaxis, yaw );
moveMap.bind( mouse, yaxis, pitch );
moveMap.bind( gamepad, thumbrx, "D", "-0.23 0.23", gamepadYaw );
moveMap.bind( gamepad, thumbry, "D", "-0.23 0.23", gamepadPitch );
moveMap.bind( gamepad, thumblx, "D", "-0.23 0.23", gamePadMoveX );
moveMap.bind( gamepad, thumbly, "D", "-0.23 0.23", gamePadMoveY );
moveMap.bind( gamepad, btn_a, jump );
moveMap.bindCmd( gamepad, btn_back, "disconnect();", "" );
moveMap.bindCmd(gamepad, dpadl, "toggleLightColorViz();", "");
moveMap.bindCmd(gamepad, dpadu, "toggleDepthViz();", "");
moveMap.bindCmd(gamepad, dpadd, "toggleNormalsViz();", "");
moveMap.bindCmd(gamepad, dpadr, "toggleLightSpecularViz();", "");
[\code]
those r the script side code for controling player's movement.
after that u can go through engine side code.
for that u have look into:
moveManager.cpp
and updateMove() from player.cpp
10/25/2012 (10:49 pm)
1st tell us, are u a programmer?if u r a programmer then look into bind()'s description from script manual.
also on "action map"
then do a look into \scripts\client\default.bind.cs
specially on these:
[code]
moveMap.bind( keyboard, a, moveleft );
moveMap.bind( keyboard, d, moveright );
moveMap.bind( keyboard, left, moveleft );
moveMap.bind( keyboard, right, moveright );
moveMap.bind( keyboard, w, moveforward );
moveMap.bind( keyboard, s, movebackward );
moveMap.bind( keyboard, up, moveforward );
moveMap.bind( keyboard, down, movebackward );
moveMap.bind( keyboard, e, moveup );
moveMap.bind( keyboard, c, movedown );
moveMap.bind( keyboard, space, jump );
moveMap.bind( mouse, xaxis, yaw );
moveMap.bind( mouse, yaxis, pitch );
moveMap.bind( gamepad, thumbrx, "D", "-0.23 0.23", gamepadYaw );
moveMap.bind( gamepad, thumbry, "D", "-0.23 0.23", gamepadPitch );
moveMap.bind( gamepad, thumblx, "D", "-0.23 0.23", gamePadMoveX );
moveMap.bind( gamepad, thumbly, "D", "-0.23 0.23", gamePadMoveY );
moveMap.bind( gamepad, btn_a, jump );
moveMap.bindCmd( gamepad, btn_back, "disconnect();", "" );
moveMap.bindCmd(gamepad, dpadl, "toggleLightColorViz();", "");
moveMap.bindCmd(gamepad, dpadu, "toggleDepthViz();", "");
moveMap.bindCmd(gamepad, dpadd, "toggleNormalsViz();", "");
moveMap.bindCmd(gamepad, dpadr, "toggleLightSpecularViz();", "");
[\code]
those r the script side code for controling player's movement.
after that u can go through engine side code.
for that u have look into:
moveManager.cpp
and updateMove() from player.cpp
#15
10/25/2012 (10:52 pm)
im learning to be a programmer. i dont know shit man! but thank 4 your help
#16
need time and large amount of patient.
u better stay with script side code.do not go to engine related code now.
look into
default.bind.cs
and
script manual for description
10/26/2012 (1:24 am)
then.as a self taught programmer, it is hard.but not impossible.need time and large amount of patient.
u better stay with script side code.do not go to engine related code now.
look into
default.bind.cs
and
script manual for description
#17
When that is accomplished you will want to have a look at scripts/client/default.bind.cs.
There you will find some functions called:
They take a parameter %val, %val is true for button down and false for button up.
To take a look at the move functions:
This global is not read by a script, but by the engine itself so this makes player move to the left. You can change the value of these globals to affect the speed of the player and which direction he is moving
10/26/2012 (1:29 am)
To add to Alfio's description, if you got your player loaded in as Dan showed you, you should be able to control him out of the box. Can you control him with WASD keys?When that is accomplished you will want to have a look at scripts/client/default.bind.cs.
There you will find some functions called:
function moveleft(%val) function moveright(%val)These functions are bound to the keys as Alfio showed above.
They take a parameter %val, %val is true for button down and false for button up.
To take a look at the move functions:
function moveleft(%val)
{
$mvLeftAction = %val * $movementSpeed;
}As you see they are setting a global (key down : $mvLeftAction = 1*speed key up = 0*speed)This global is not read by a script, but by the engine itself so this makes player move to the left. You can change the value of these globals to affect the speed of the player and which direction he is moving
#18
10/26/2012 (3:58 am)
Yeah, I didn't have to modify default.bind.cs at all. I followed that tut and it just worked. Albeit with some glitchy (but hilarious) animations.
#19
Britt Scott has offered a very nice Xbox 360 Controller script that works for player and vehicle in the Resource section.
www.garagegames.com/community/blogs/view/21957
10/26/2012 (9:45 pm)
@ Dominic,Britt Scott has offered a very nice Xbox 360 Controller script that works for player and vehicle in the Resource section.
www.garagegames.com/community/blogs/view/21957
#20
10/27/2012 (6:50 pm)
@Ahsan - Forward slash mate. Forward slash.moveMap.bind( keyboard, a, moveleft ); moveMap.bind( keyboard, d, moveright ); moveMap.bind( keyboard, left, moveleft ); moveMap.bind( keyboard, right, moveright ); moveMap.bind( keyboard, w, moveforward ); moveMap.bind( keyboard, s, movebackward ); moveMap.bind( keyboard, up, moveforward ); moveMap.bind( keyboard, down, movebackward ); moveMap.bind( keyboard, e, moveup ); moveMap.bind( keyboard, c, movedown ); moveMap.bind( keyboard, space, jump ); moveMap.bind( mouse, xaxis, yaw ); moveMap.bind( mouse, yaxis, pitch ); moveMap.bind( gamepad, thumbrx, "D", "-0.23 0.23", gamepadYaw ); moveMap.bind( gamepad, thumbry, "D", "-0.23 0.23", gamepadPitch ); moveMap.bind( gamepad, thumblx, "D", "-0.23 0.23", gamePadMoveX ); moveMap.bind( gamepad, thumbly, "D", "-0.23 0.23", gamePadMoveY ); moveMap.bind( gamepad, btn_a, jump ); moveMap.bindCmd( gamepad, btn_back, "disconnect();", "" ); moveMap.bindCmd(gamepad, dpadl, "toggleLightColorViz();", ""); moveMap.bindCmd(gamepad, dpadu, "toggleDepthViz();", ""); moveMap.bindCmd(gamepad, dpadd, "toggleNormalsViz();", ""); moveMap.bindCmd(gamepad, dpadr, "toggleLightSpecularViz();", "");
Torque Owner Lukas Joergensen
WinterLeaf Entertainment