how to replace a player animation sequence with another one?
by Ahsan Muzaheed · in Artist Corner · 10/25/2011 (6:17 pm) · 8 replies
for example if i want to change player's run animation to another one when he is holding a weapon,what i have to do?
i have tried this:
$anim[0]= "./MoveFast.dsq";
$anim[1]= "./WeaponMoveFast.dsq";
although it is replacing the animation in memory,but it is not replacing the animation in game play.still it is playing the old sequence.
may be i need to reload the animation.how to do that?
[edited]
i have tried to assign "WeaponMoveFast.dsq" sequence to run.
$store.addSequence($anim[1], "run", "0", "24");
it shows:
TSShape::addSequence: Failed to add sequence 'run' (name already exists)
i have tried this:
$anim[0]= "./MoveFast.dsq";
$anim[1]= "./WeaponMoveFast.dsq";
function TF341_05BDts::onLoad(%this)
{
................................
%this.addSequence($anim[0], "run", "0", "15");
...............................
}
if(condition)
{
...........................
$anim[0]=$anim[1];
}although it is replacing the animation in memory,but it is not replacing the animation in game play.still it is playing the old sequence.
may be i need to reload the animation.how to do that?
[edited]
i have tried to assign "WeaponMoveFast.dsq" sequence to run.
$store.addSequence($anim[1], "run", "0", "24");
it shows:
TSShape::addSequence: Failed to add sequence 'run' (name already exists)
About the author
Torque 3D enthusiastic since 2010.Have been working in several T3D projects besides of Unreal Engine 4 and Unity 3D. NEED a hand with your project? SHoot me a mail. http://www.garagegames.com/community/forums /viewthread/138437/
#3
my player model is located in
"game/coustomObjects/testSoldierPlayer/soldiers".
i have tried this in game\scripts\server\commands.cs's
i have tested it in shape editor,it works.but the problem is in game player running still with the old sequence(WeaponMoveFast.dsq).how to make him to run with new sequence (MoveFast.dsq)
and i hate this forum's posting system.very much annoying.
10/28/2011 (11:47 am)
thanks for the answer.my player model is located in
"game/coustomObjects/testSoldierPlayer/soldiers".
i have tried this in game\scripts\server\commands.cs's
function serverCmdThrow(%client, %data)
{
%player = %client.player;
if(!isObject(%player) || %player.getState() $= "Dead" || !$Game::Running)
return;
switch$ (%data)
{
case "Weapon":
%item = (%player.getMountedImage($WeaponSlot) == 0) ? "" : %player.getMountedImage($WeaponSlot).item;
if (%item !$="")
%player.throw(%item);
(fileBase( %player.getDataBlock( ).shapefile)@"Dts2").removeSequence("run");//AHM--removing sequence
(fileBase( %player.getDataBlock( ).shapefile)@"Dts2").addSequence("coustomObjects/testSoldierPlayer/soldiers/MoveFast.dsq", "run", "0", "-1");//AHM--adding sequence
(fileBase( %player.getDataBlock( ).shapefile)@"Dts2").setSequenceCyclic("run", "1");//AHM--make it cyclici have tested it in shape editor,it works.but the problem is in game player running still with the old sequence(WeaponMoveFast.dsq).how to make him to run with new sequence (MoveFast.dsq)
and i hate this forum's posting system.very much annoying.
#4
However, it is possible through source modification to add alternate animation threads that work much like how the armthreads work. This would allow different run/walk animations to be used depending on what weapon is equipped.
10/28/2011 (1:49 pm)
I don't think that dynamically altering a TSShapeConstructor during gameplay is intended or supported with stock code. It's my understanding that it's exec'd at runtime (animations loaded/merged/etc) and that's what you get.However, it is possible through source modification to add alternate animation threads that work much like how the armthreads work. This would allow different run/walk animations to be used depending on what weapon is equipped.
#5
maybe something like this;
10/28/2011 (2:02 pm)
Thats the issue ... it only works when the model is first loaded, not dynamically afterwards.maybe something like this;
function TF341_05BDts2::onLoad(%this)
{ %this.removeSequence("run")
%this.addSequence("./IDLE.dsq", "root", "0", "24");
%this.addSequence("./MoveFastRiffle.dsq", "run", "0", "15");
%this.addSequence("./backW.dsq", "back", "0", "-1");
}
#6
grabbing a weapon will delete player shape from screen.and then reload it quickly with another second datablock and place player shape in the same position holding weapon.
10/28/2011 (5:23 pm)
is it possible:grabbing a weapon will delete player shape from screen.and then reload it quickly with another second datablock and place player shape in the same position holding weapon.
#7
...I don't know what you are trying to get working here....sounds as though you are reinventing the wheel.
Why are you switching datablocks of the player simply because you've mounted a weapon?? Weapon images call an animation to play when a 'weapon' is mounted to the player.
What exactly are you trying to achieve in gameplay? Why delete the player object just because it's mounting an object? To run a different sequence?
10/29/2011 (4:58 am)
Yep; do all your 'constructing' of shapes BEFORE the object gets loaded into memory....I don't know what you are trying to get working here....sounds as though you are reinventing the wheel.
Why are you switching datablocks of the player simply because you've mounted a weapon?? Weapon images call an animation to play when a 'weapon' is mounted to the player.
What exactly are you trying to achieve in gameplay? Why delete the player object just because it's mounting an object? To run a different sequence?
#8
which animation?
i want to replace existing animation with other sequences.
more details in below.
i want To run different sequences for run,crouch and for other movements.
naturally,when you carry an weapon your running style and other style changes.
see the stock Gideon and soldier model.it looks funny when you throw your weapon and they still runs in the style of carrying a weapon.
10/29/2011 (9:31 am)
Quote:
Weapon images call an animation to play when a 'weapon' is mounted to the player.
which animation?
i want to replace existing animation with other sequences.
more details in below.
Quote:
Why delete the player object just because it's mounting an object? To run a different sequence?
i want To run different sequences for run,crouch and for other movements.
naturally,when you carry an weapon your running style and other style changes.
see the stock Gideon and soldier model.it looks funny when you throw your weapon and they still runs in the style of carrying a weapon.
Ahsan Muzaheed
Default Studio Name
or
my question is not clear?
my player's model(TF341_05B.dts) has this datablock
function TF341_05BDts2::onLoad(%this) { %this.addSequence("./IDLE.dsq", "root", "0", "24"); %this.addSequence("./MoveFastRiffle.dsq", "run", "0", "15"); %this.addSequence("./backW.dsq", "back", "0", "-1"); }so when player will run engine will play MoveFast.dsq.
when he grab a weapon,i want to change run animation to another file(WeaponMoveFastRiffle.dsq).how to do that?