Page 1 of 1
Jumping Animations
Posted: Sat Mar 15, 2008 2:33 pm
by Danimita92
When the player jumps, I notice if i hit the "Forward" button while it's in the air, it plays the Walks animation. How can i set it so if it's in the air and you hit any directional button, the player plays certain animations? Like "AirWalk" or "Airslidetoleft" etc... (These animation would be done by me obviously)
Re: Jumping Animations
Posted: Sat Mar 15, 2008 5:06 pm
by darksmaster923
it depends. are you using a scripted player or built in player. but i have never seen the built in player do this so i am going to assume you have a scripted player.
well first you have to set a variable in your script called like jumping or whatever. then when the player jumps if sets variable jumping = true, now in the movement orders you set if(jumping = true)
then instead of doing the normal animations you do that airwalk animations. then you put else at the end so it executes the walk animation like so
Code: Select all
if(jumping = true)
{
Animate(walk);
}
else
{
Animate(jumpwalk);
}
then you add an order that runs from the main loops that says
if(self.IsFalling = false)
theres other ways i havent tested it yet but you get the idea
Re: Jumping Animations
Posted: Sat Mar 15, 2008 7:39 pm
by Danimita92
Umm... it's actually the built in player. I'd rather use a built in player since it's much easier, and I'm new to scripting. I'd like the player to have different animations while it's jumping, depending on the direction. (forward, backwards, left, right...)
I'd also rather the built in player because of the distance order scripts, unless you can make them look for the scripted player.
Re: Jumping Animations
Posted: Sat Mar 15, 2008 9:49 pm
by darksmaster923
Danimita92 wrote:Umm... it's actually the built in player. I'd rather use a built in player since it's much easier, and I'm new to scripting. I'd like the player to have different animations while it's jumping, depending on the direction. (forward, backwards, left, right...)
I'd also rather the built in player because of the distance order scripts, unless you can make them look for the scripted player.
well you can calulate the distance with scripted player easily. the main problem is that the built in player is limited and you can only use a limited amount of animations. it shouldnt be playing the walk animation in midair either, so i dunno how you would do this.
Re: Jumping Animations
Posted: Sun Mar 23, 2008 2:32 pm
by Danimita92
Hi, I decided to create this in my scripted player, but it doesn't seem to work. Can anyone tell me what's wrong?
Code: Select all
{
FIREAMMO [pistolbullet] // Projectile fired by pawn
FIREEFFECT [Electric] // muzzleflash effect
WEAPONMODEL [Laser] // Weapon held by pawn
FIRERATE [0.1] // Weapon firing rate
GROUP [Friendly] // Pawn Group - must be targetted by enemies
PLAYERSPEED [106] // Walk Speed
HEALTHATTRIB [health] // health attribute given to pawn
HEALTHAMOUNT [500] // amount of health given to pawn
DAMAGEATTRIB [health] // Atribute damaged by pawn
BOX [24] // Box width
IDLEANIM [Idle] // Idle AnimationSpeed
SHOOTANIM [recon_shoot] // Shoot anim
WALKANIM [Walk] // Walk anim
RUNANIM [Run] // Run anim
JUMPANIM [Jump] //Jump anim
BACKANIM [WalkBack] // walk back anim
STRAFELEFT [WalkLeft] // Strafe left anim
RUNLEFT [RunLeft] //Run Left anim
STRAFERIGHT [WalkRight] // Strafe right anim
RUNRIGHT [RunRight] // Run right anim
INTERANIM [recon_strike] // Pawn interact anim
DEATHANIM [recon_die] // Death Anim
ROOTBONE [Bip01] // Pawn root bone
WEAPONHAND [Bip01 L Hand] // Pawn weapon bone
IDLEJUMPANIM [Jump] //Jump in idle
PREPANIM [PrepareToJump] //About toggle jump anim
AIRRUNANIM [AirRun] //Forward Jumping animation
AIRRUNLEFTANIM [AirRunLeft] //Left Jumping animation
AIRRUNRIGHTANIM [AirRunRight] // Right Jumping animation
K_INTER [29] // INTERACT KEY - F
K_FIRE [72] // FIRE KEY - LEFT MOUSE
K_FOR [15] // FORWARD - W
K_BAK [27] // BACK - S
K_LEFT [26] // STRAFE LEFT - A
K_RIGHT [28] // STRAFE RIGHT - D
K_RUN [36] // RUN - LEFT SHIFT KEY
K_JUMP [46] //Jump - SPACE
ANIM [string] // Do Not Edit
ANC [0] // Do Not Edit
LASTANC [0] // Do Not Edit
DIR [0] // Do Not Edit
AT [0.5] // Do Not Edit
INTER [string] // Do Not Edit
TM [0] // Do Not Edit
SPEED [0] //Do Not Edit
jumping [0]
Spawn[()
{
Console(true);
BoxWidth(BOX);
SetGroup(GROUP);
AttributeOrder(HEALTHATTRIB,HEALTHAMOUNT,"Die");
LowLevel("Setup");
}]
Setup[()
{
self.yaw_speed=256;
AnimateHold(IDLEANIM);
ANIM=StringCopy(IDLEANIM);
ANC=0;
LASTANC=0;
TM=self.time;
self.think="RunPlayer";
}]
RunPlayer[()
{
//debug(self.key_pressed);
PlayerRender(false);
self.ideal_yaw=self.player_yaw;
ChangeYaw();
DIR=0; // Default straight
SPEED=0; //Default - no motion
AT=0.1; //Default
ANC=0; //Default
AnimationSpeed(1); //Default
//handle health status
if(self.health < 1)
{
HighLevel("Die");
return 0;
}
//handle controls
if(IsKeyDown(K_INTER))
{
//strike/interact
AnimateBlend(INTERANIM,0.25);
self.think="Interact";
return 0;
}
if(IsKeyDown(K_JUMP))
{
//jump
ForceUp(50);
jumping=1;
}
if(jumping = 1)
{
if(ANC = 2)
{
ANIM=StringCopy(AIRRUNANIM);
SPEEDED=Integer(PLAYERSPEED);
}
if(ANC = 3)
{
ANIM=StringCopy(AIRRUNANIM);
DIR=ConvertDegrees(180);
SPEED=Integer(PLAYERSPEED);
}
if(ANC = 4)
{
ANIM=StringCopy(AIRRUNLEFTANIM);
AT=0.5;
DIR=ConvertDegrees(90);
SPEED=Integer(PLAYERSPEED);
}
if(ANC = 5)
{
ANIM=StringCopy(AIRRUNRIGHTANIM);
AT=0.5;
ANC=5;
DIR=ConvertDegrees(270);
SPEED=Integer(PLAYERSPEED);
}
if(ANC < 1)
{
ANIM=StringCopy(JUMPANIM);
AT=0.5;
}
if(self.IsFalling = false)
{
jumping=0;
}
}
if(IsKeyDown(K_FOR))
{
//forward
ANIM=StringCopy(WALKANIM);
ANC=2;
SPEED=Integer(PLAYERSPEED);
}
if(IsKeyDown(K_BAK))
{
//back
ANIM=StringCopy(BACKANIM);
ANC=3;
DIR=ConvertDegrees(180);
SPEED=Integer(PLAYERSPEED);
}
if(IsKeyDown(K_LEFT))
{
//strafe left
ANIM=StringCopy(STRAFELEFT);
//make strafe transition smoother
AT=0.5;
ANC=4;
DIR=ConvertDegrees(90);
SPEED=Integer(PLAYERSPEED);
}
if(IsKeyDown(K_RIGHT))
{
//strafe right
ANIM=StringCopy(STRAFERIGHT);
//make strafe transition smoother
AT=0.5;
ANC=5;
DIR=ConvertDegrees(270);
SPEED=Integer(PLAYERSPEED);
}
if(IsKeyDown(K_FIRE))
{
//fire
if(ANC < 1)
{
//only go to shoot anim if at idle
ANIM=StringCopy(SHOOTANIM);
ANC=1;
}
// Check fire rate
if(self.time > TM+FIRERATE)
{
TM=self.time;
FireProjectileBlind(FIREAMMO,WEAPONHAND,0,0,0,DAMAGEATTRIB);
AddExplosion(FIREEFFECT,WEAPONHAND,0,0,0);
TM=self.time;
}
}
if(ANC < 1)
{
//no button
ANIM=StringCopy(IDLEANIM);
AT=0.5;
}
if(IsKeyDown(K_RUN))
{
//left shift key - toggle run
AnimationSpeed(1);
SPEED=SPEED+(SPEED*2);
if(IsKeyDown(K_FOR))
{
//run forward
ANIM=StringCopy(RUNANIM);
ANC=2;
}
if(IsKeyDown(K_LEFT))
{
//run left
ANIM=StringCopy(RUNLEFT);
//make strafe transition smoother
AT=0.5;
ANC=4;
DIR=ConvertDegrees(90);
}
if(IsKeyDown(K_RIGHT))
{
//run right
ANIM=StringCopy(RUNRIGHT);
//make strafe transition smoother
AT=0.5;
ANC=5;
DIR=ConvertDegrees(270);
}
}
//handle animations
if(Integer(LASTANC) != Integer(ANC))
{
AnimateBlend(ANIM,AT);
}
LASTANC=Integer(ANC);
if(self.animate_at_end)
{
AnimateHold(ANIM);
}
//handle motions
walkmove(self.current_yaw+DIR,SPEED);
}]
Interact[()
{
if(self.animate_at_end)
{
INTER=TraceToActor(ROOTBONE,0,0,32);
if(INTER != "FALSE")
{
SetEventState(INTER # "Trigger",true);
}
self.think="RunPlayer";
return 0;
}
}]
Die[()
{
AnimateStop(DEATHANIM,0,"");
}]
}
I got it from somewhere (can't remember where) And just modified things a bit and included the jumping.
Re: Jumping Animations
Posted: Sun Mar 23, 2008 5:05 pm
by darksmaster923
thats genericplayer.s what does the console say?
Re: Jumping Animations
Posted: Sun Mar 23, 2008 6:00 pm
by Jay
If there is no console, try to change the 'jumping' variable to something else, like 'B_JUMP'. There are 'reserved' variable names that cause the script not to work, and 'jumping' sounds a bit to common. (So it could be a reserved variable name) I know that sounds strange but i ran into this issue once when i tried to implement something with time and it always gave me reader script errors.
Re: Jumping Animations
Posted: Sun Mar 23, 2008 6:44 pm
by Danimita92
I tried what Jay said, and still doesn't work.
The console just says I'm in the RunPlayer order.
The pawn jumps, but the animations are the walk/run animations...
Re: Jumping Animations
Posted: Sun Mar 23, 2008 7:54 pm
by bernie
Here is a copy of genericplayer.s I played around with. I works in a fashion but it needs tidying up a lot. You're welcome to use it if you wish. The crouch routine hasn't got a camera attatched so you will have to do that yourself. I was also having trouble with head clearance in the Jump routine which I don't think I fully sorted out.
{
FIREAMMO [pistolbullet] // Projectile fired by pawn
FIREEFFECT [Electric] // muzzleflash effect
WEAPONMODEL [PawnSword] // Weapon held by pawn
FIRERATE [0.1] // Weapon firing rate
GROUP [Friendly] // Pawn Group - must be targetted by enemies
PLAYERSPEED [96] // Walk Speed
PLAYERRUNSPEED [144] //Run Speed
HEALTHATTRIB [health] // health attribute given to pawn
HEALTHAMOUNT [500] // amount of health given to pawn
DAMAGEATTRIB [health] // Atribute damaged by pawn
BOX [24] // Box width
IDLEANIM [Idle] // Idle AnimationSpeed
SHOOTANIM [Slash1] // Shoot anim
RUNANIM [Run] // Run anim
RUNBACKANIM [RunBack] //Run Back anim
WALKANIM [Walk] //Walk anim
BACKANIM [WalkBack] // walk back anim
STRAFELEFT [StrafeLeft] // Strafe left anim
STRAFERIGHT [StrafeRight] // Strafe right anim
INTERANIM [Slash1] // Pawn interact anim
CROUCHANIM [C_Idle] //Crouch Anim
CRAWLANIM [Crawl] // Crawl Anim
CRAWLBACKANIM [CrawlBack] // Crawl Back Anim
CSTRAFELANIM [StrafeCLeft] // Crawl Strafe Left
CSTRAFERANIM [StrafeCRight] // Crawl Strafe Right
JUMPANIM [Jump] //Jump Anim
DEATHANIM [Die] // Death Anim
ROOTBONE [BIP01] // Pawn root bone
WEAPONHAND [BIP01 R HAND] // Pawn weapon bone
MAXJMPHT [40] //max jump height
K_INTER [73] // INTERACT KEY - RIGHT MOUSE
K_FIRE [72] // FIRE KEY - LEFT MOUSE
K_FOR [15] // FORWARD - W
K_BAK [27] // BACK - S
K_LEFT [26] // STRAFE LEFT - A
K_RIGHT [28] // STRAFE RIGHT - D
K_RUN [36] // RUN - LEFT SHIFT KEY
K_CROUCH [39] // CROUCH
K_JUMP [46] //Jump
ANIM [string] // Do Not Edit Next to animate
ANC [0] // Do Not Edit Current key pressed
LASTANC [0] // Do Not Edit Last key pressed
DIR [0] // Do Not Edit direction of movement
AT [0.5] // Do Not Edit blend timem
INTER [string] // Do Not Edit interact key
TM [0] // Do Not Edit timer
SPEED [0] //Do Not Edit speed of movement
RN [false] //Do Not Edit run flag
CWL[false] //Do Not Edit crawl flag
CDV [0] //Do Not Edit head clearance
JMPHT [40]//Do Not Edit jump height
Spawn[()
{
Console(true);
BoxWidth(BOX);
SetGroup(GROUP);
AttributeOrder(HEALTHATTRIB,HEALTHAMOUNT,"Die");
SetWeapon(WEAPONMODEL);
LowLevel("Setup");
}]
Setup[()
{
AttachCamera();
self.yaw_speed=256;
//AnimateHold(IDLEANIM);
//ANIM=StringCopy(IDLEANIM);
ANC=0;
LASTANC=0;
CWL=0;
TM=self.time;
self.think="RunPlayer";
}]
RunPlayer[()
{
//debug(self.key_pressed);
debug(JMPHT);
PlayerRender(true);
self.ideal_yaw=self.player_yaw;
ChangeYaw();
CDV = GetCollideDistance("BIP01 HEAD", 0, 400, 0 );
DIR=0; // Default straight
SPEED=0; //Default - no motion
AT=0.1; //Default
ANC=0; //Default
JMPHT = MAXJMPHT; //Default
AnimationSpeed(1); //Default
//handle health status
if(self.health < 1)
{
HighLevel("Die");
return 0;
}
//handle controls
if(IsKeyDown(K_INTER))
{
//strike/interact
AnimateBlend(INTERANIM,0.25);
self.think="Interact";
return 0;
}
if(IsKeyDown(K_FOR))
{
//forward
ANIM=StringCopy(WALKANIM);
ANC=2;
SPEED=Integer(PLAYERSPEED);
if(RN = true) // If Run flag true
{
ANIM=StringCopy(RUNANIM);
SPEED=Integer(PLAYERRUNSPEED);
}
if(CWL =true) // If Crawl flag true
{
ANIM=StringCopy(CRAWLANIM);
SPEED=Integer(PLAYERSPEED);
}
}
if(IsKeyDown(K_BAK))
{
//back
ANIM=StringCopy(BACKANIM);
ANC=3;
DIR=ConvertDegrees(180);
SPEED=Integer(PLAYERSPEED);
if(RN = true) // If Run flag true
{
ANIM=StringCopy(RUNBACKANIM);
SPEED=Integer(PLAYERRUNSPEED);
}
if(CWL = true) // If Crawl flag true
{
ANIM=StringCopy(CRAWLBACKANIM);
SPEED=Integer(PLAYERSPEED);
}
}
if(IsKeyDown(K_LEFT))
{
//strafe left
ANIM=StringCopy(STRAFELEFT);
if(CWL = true) // If Crawl flag true
{
ANIM=StringCopy(CSTRAFELANIM);
}
//make strafe transition smoother
AT=0.5;
ANC=4;
DIR=ConvertDegrees(90);
SPEED=Integer(PLAYERSPEED);
}
if(IsKeyDown(K_RIGHT))
{
//strafe right
ANIM=StringCopy(STRAFERIGHT);
if(CWL = true) // If Crawl flag true
{
ANIM=StringCopy(CSTRAFERANIM);
}
//make strafe transition smoother
AT=0.5;
ANC=5;
DIR=ConvertDegrees(270);
SPEED=Integer(PLAYERSPEED);
}
if(IsKeyDown(K_FIRE))
{
//fire
if((ANC < 1)and(CWL=false)) //only go to shoot anim if at idle and not crouching
{
ANIM=StringCopy(SHOOTANIM);
ANC=1;
}
// Check fire rate
if(self.time > TM+FIRERATE)
{
TM=self.time;
FireProjectileBlind(FIREAMMO,WEAPONHAND,0,0,0,DAMAGEATTRIB);
AddExplosion(FIREEFFECT,WEAPONHAND,0,0,0);
TM=self.time;
}
}
if(ANC < 1)
{
//no button
AT=0.5;
if(CWL = true) // If Crawl flag true
{
ANIM=StringCopy(CROUCHANIM);
}
else
{
ANIM=StringCopy(IDLEANIM);
}
}
if(IsKeyDown(K_RUN))
{
// Toggle run
ANC = 6;
if(Integer(LASTANC) != Integer(ANC))
{
if(RN = true)
{
RN = false;
}
else
{
RN = true;
}
LASTANC=Integer(ANC);
}
}
if(IsKeyDown(K_CROUCH))
{
// Toggle Crouch
ANC=7;
if(Integer(LASTANC) != Integer(ANC))
{
AT=0.5;
if((CWL = true)and(CDV > 21.5))// cant stand up if not enough clearance
{
CWL = false;
SetBoundingBox(IDLEANIM,24);
}
else
{
CWL = true;
SetBoundingBox(CRAWLANIM,0);
}
LASTANC=Integer(ANC);
}
return 0;
}
if(IsKeyDown(K_JUMP))
{
//Jump
ANC=8;
if((Integer(LASTANC) != Integer(ANC))and(CDV > JMPHT+14))
//if((Integer(LASTANC) != Integer(ANC))and(CWL=false)) //cant jump from crouching
{
LASTANC=Integer(ANC);
HighLevel("Jumpup");
return 0;
}
}
//handle animations
if(Integer(LASTANC) != Integer(ANC))
{
AnimateBlend(ANIM,AT);
}
LASTANC=Integer(ANC);
if(self.animate_at_end)
{
AnimateHold(ANIM);
}
//handle motions
walkmove(self.current_yaw+DIR,SPEED);
}]
Jumpup[()
{
JMPHT = CDV; // make sure enough clearance to jump
if(JMPHT > MAXJMPHT)
{
JMPHT=MAXJMPHT;
}
if(JMPHT<18) //cant jump higher than bounding box
{
JMPHT=0;
}
//BlendToAnimation(JUMPANIM,0.25,false,"");
BlendToAnimation("JumpStart",0.1,false,"");
BlendToAnimation("Jump",0.25,false,"");
//AnimationSpeed(0.25);
Jump("",JMPHT, true, "" );
BlendToAnimation("Land",0.1,false,"");
//BlendToAnimation(ANIM,0.35,false,"");
LowLevel("RunPlayer");
}]
Interact[()
{
if(self.animate_at_end)
{
INTER=TraceToActor(ROOTBONE,0,0,32);
if(INTER != "FALSE")
{
SetEventState(INTER # "Trigger",true);
}
self.think="RunPlayer";
return 0;
}
}]
Die[()
{
AnimateStop(DEATHANIM,0,"");
}]
}
Re: Jumping Animations
Posted: Sun Mar 23, 2008 8:26 pm
by Danimita92
Actually I'd prefer to keep on with mine since it's a script I'm practicing on. So if someone can tell me what's wrong in it...
Re: Jumping Animations
Posted: Mon Mar 24, 2008 9:36 am
by Jay
Hm. Maybe try to put the jumping-part after the part with running and so, otherwise it will just override those animations with the walk/run animations if you press forward or so. Chaning animations in low level can be a pain because it always just uses the last animation specified. So if you have specified two after another, the first one looses.
As a general rule, the most important animation should come last. (So that even if there was another animation before, it will be overidden.)
Re: Jumping Animations
Posted: Mon Mar 24, 2008 11:32 pm
by Danimita92
I tried, didn't work. I'm trying a new way, something like:
if(IsKeyDown(K_FOR))
{
if(self.IsFalling=false)
{
//forward
ANIM=StringCopy(WALKANIM);
ANC=2;
SPEED=Integer(PLAYERSPEED);
}
if(self.IsFalling=true)
{
SPEED=Integer(PLAYERSPEED);
ANIM=StringCopy(AIRRUNANIM);
AnimateBlend(ANIM,2);
}
}
Using AnimateBlend I managed to make the animation's first frame show, but it'll only play if I release the KEY_FOR key. Any idea how to fix this?
Re: Jumping Animations
Posted: Tue Mar 25, 2008 5:02 pm
by Danimita92
Okay ignore my last post, I've decided to make a different order for the jumping part, in high level. THe problem is when I hit the jumping button it'll shut down the game, and it'll say "Reality Factory has had a problem and must shut down" Or something like that, coz I'm translating it. Heres my script:
Code: Select all
{
FIREAMMO [pistolbullet] // Projectile fired by pawn
FIREEFFECT [Electric] // muzzleflash effect
WEAPONMODEL [Laser] // Weapon held by pawn
FIRERATE [0.1] // Weapon firing rate
GROUP [Friendly] // Pawn Group - must be targetted by enemies
PLAYERSPEED [106] // Walk Speed
HEALTHATTRIB [health] // health attribute given to pawn
HEALTHAMOUNT [500] // amount of health given to pawn
DAMAGEATTRIB [health] // Atribute damaged by pawn
BOX [24] // Box width
IDLEANIM [Idle] // Idle AnimationSpeed
SHOOTANIM [recon_shoot] // Shoot anim
WALKANIM [Walk] // Walk anim
RUNANIM [Run] // Run anim
JUMPANIM [Jump] //Jump anim
BACKANIM [WalkBack] // walk back anim
STRAFELEFT [WalkLeft] // Strafe left anim
RUNLEFT [RunLeft] //Run Left anim
STRAFERIGHT [WalkRight] // Strafe right anim
RUNRIGHT [RunRight] // Run right anim
INTERANIM [recon_strike] // Pawn interact anim
DEATHANIM [recon_die] // Death Anim
ROOTBONE [Bip01] // Pawn root bone
WEAPONHAND [Bip01 L Hand] // Pawn weapon bone
IDLEJUMPANIM [Jump] //Jump in idle
PREPANIM [PrepareToJump] //About toggle jump anim
AIRRUNANIM [AirRun] //Forward Jumping animation
AIRRUNLEFTANIM [AirRunLeft] //Left Jumping animation
AIRRUNRIGHTANIM [AirRunRight] // Right Jumping animation
K_INTER [29] // INTERACT KEY - F
K_FIRE [72] // FIRE KEY - LEFT MOUSE
K_FOR [15] // FORWARD - W
K_BAK [27] // BACK - S
K_LEFT [26] // STRAFE LEFT - A
K_RIGHT [28] // STRAFE RIGHT - D
K_RUN [36] // RUN - LEFT SHIFT KEY
K_JUMP [46] //Jump - SPACE
ANIM [string] // Do Not Edit
ANC [0] // Do Not Edit
LASTANC [0] // Do Not Edit
DIR [0] // Do Not Edit
AT [0.5] // Do Not Edit
INTER [string] // Do Not Edit
TM [0] // Do Not Edit
SPEED [0] //Do Not Edit
jumping [0]
Spawn[()
{
Console(true);
BoxWidth(BOX);
SetGroup(GROUP);
AttributeOrder(HEALTHATTRIB,HEALTHAMOUNT,"Die");
LowLevel("Setup");
}]
Setup[()
{
self.yaw_speed=256;
AnimateHold(IDLEANIM);
ANIM=StringCopy(IDLEANIM);
ANC=0;
LASTANC=0;
TM=self.time;
self.think="RunPlayer";
}]
RunPlayer[()
{
//debug(self.key_pressed);
PlayerRender(false);
self.ideal_yaw=self.player_yaw;
ChangeYaw();
DIR=0; // Default straight
SPEED=0; //Default - no motion
AT=0.1; //Default
ANC=0; //Default
AnimationSpeed(1); //Default
//handle health status
if(self.health < 1)
{
HighLevel("Die");
return 0;
}
//handle controls
if(IsKeyDown(K_INTER))
{
//strike/interact
AnimateBlend(INTERANIM,0.25);
self.think="Interact";
return 0;
}
if(IsKeyDown(K_JUMP))
{
//jump
HighLevel(Falling);
return 0;
}
if(IsKeyDown(K_FOR))
{
//forward
ANIM=StringCopy(WALKANIM);
ANC=2;
SPEED=Integer(PLAYERSPEED);
}
if(IsKeyDown(K_BAK))
{
//back
ANIM=StringCopy(BACKANIM);
ANC=3;
DIR=ConvertDegrees(180);
SPEED=Integer(PLAYERSPEED);
}
if(IsKeyDown(K_LEFT))
{
//strafe left
ANIM=StringCopy(STRAFELEFT);
//make strafe transition smoother
AT=0.5;
ANC=4;
DIR=ConvertDegrees(90);
SPEED=Integer(PLAYERSPEED);
}
if(IsKeyDown(K_RIGHT))
{
//strafe right
ANIM=StringCopy(STRAFERIGHT);
//make strafe transition smoother
AT=0.5;
ANC=5;
DIR=ConvertDegrees(270);
SPEED=Integer(PLAYERSPEED);
}
if(IsKeyDown(K_FIRE))
{
//fire
if(ANC < 1)
{
//only go to shoot anim if at idle
ANIM=StringCopy(SHOOTANIM);
ANC=1;
}
// Check fire rate
if(self.time > TM+FIRERATE)
{
TM=self.time;
FireProjectileBlind(FIREAMMO,WEAPONHAND,0,0,0,DAMAGEATTRIB);
AddExplosion(FIREEFFECT,WEAPONHAND,0,0,0);
TM=self.time;
}
}
if(ANC < 1)
{
//no button
ANIM=StringCopy(IDLEANIM);
AT=0.5;
}
if(IsKeyDown(K_RUN))
{
//left shift key - toggle run
AnimationSpeed(1);
SPEED=SPEED+(SPEED*2);
if(IsKeyDown(K_FOR))
{
//run forward
ANIM=StringCopy(RUNANIM);
ANC=2;
}
if(IsKeyDown(K_LEFT))
{
//run left
ANIM=StringCopy(RUNLEFT);
//make strafe transition smoother
AT=0.5;
ANC=4;
DIR=ConvertDegrees(90);
}
if(IsKeyDown(K_RIGHT))
{
//run right
ANIM=StringCopy(RUNRIGHT);
//make strafe transition smoother
AT=0.5;
ANC=5;
DIR=ConvertDegrees(270);
}
}
//handle animations
if(Integer(LASTANC) != Integer(ANC))
{
AnimateBlend(ANIM,AT);
}
LASTANC=Integer(ANC);
if(self.animate_at_end)
{
AnimateHold(ANIM);
}
//handle motions
walkmove(self.current_yaw+DIR,SPEED);
}]
Interact[()
{
if(self.animate_at_end)
{
INTER=TraceToActor(ROOTBONE,0,0,32);
if(INTER != "FALSE")
{
SetEventState(INTER # "Trigger",true);
}
self.think="RunPlayer";
return 0;
}
}]
Die[()
{
AnimateStop(DEATHANIM,0,"");
}]
Falling[()
{
if(self.IsFalling=true)
{
if(IsKeyDown(K_FOR))
{
SPEED=Integer(PLAYERSPEED);
ANIM=StringCopy(AIRRUNANIM);
BlendToAnimation("AIRRUNANIM",1,false,"");
}
if(IsKeyDown(K_LEFT))
{
SPEED=Integer(PLAYERSPEED);
ANIM=StringCopy(AIRRUNLEFTANIM);
BlendToAnimation("AIRRUNLEFTANIM",1,false,"");
}
if(self.IsFalling=false)
{
LowLevel("RunPlayer");
}
}
}]
}
Re: Jumping Animations
Posted: Thu Mar 27, 2008 9:43 pm
by Danimita92
Okay I managed to get nearer to where i want, but i need just a little easy doubt resolved. I want to make my pawn jump in high level scripting. I tried the Jump command but it'll barely lift up from the ground. How can i set how high the pawn jumps?
EDIT: Never mind, I found out SPEED also represented Jump height.