Forum

Rewriting Quake's player animation code..

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Rewriting Quake's player animation code..

Postby DusterdooSmock » Wed Nov 09, 2011 1:12 am

I started to re-write Quake's player animation code today (to be easier expanded and understood easier), and so far it's going great.

But, now I have come across a couple of roadblocks...

1). I need some help of figuring out how the make it so that if the player's velocity is 0, and the run animation is past a certain point (IE, the point where the player lifts his first leg off of the ground), then continue the animation until it is done, otherwise, stop the animation.

2). For some reason, for the first few tenths of a second when the player is first spawned, the animation plays really slow..

Here's the code...

In defs.qc:
Code: Select all
void() player_run;
float RUN_START   = 7;
float RUN_END   = 12;
.float anim_time;


In client.qc:
Code: Select all
In PutClientInServer:
self.frame = RUN_START;

In PlayerPostThink:
player_run();


And finally, in player.qc:
Code: Select all
void() player_run =
{
   if(time < self.anim_time)
      return;

   if(self.velocity_x)
   {
      self.frame = (self.frame + 1);
         
      if(self.frame == RUN_END)
         self.frame = RUN_START;
         
      self.anim_time = (self.anim_time + 0.1);
      return;
   }
   else
   {
      self.anim_time = time;
      return;
   }
};


Thanks in advance.
- Duster
DusterdooSmock
 
Posts: 170
Joined: Thu Aug 19, 2010 9:58 pm

Re: Rewriting Quake's player animation code..

Postby Nahuel » Wed Nov 09, 2011 1:49 am

void() player_run =
{
if (self.velocity_x <= 0 )
return;
else
{
self.frame = (self.frame + 1);

if(self.frame == RUN_END)
self.frame = RUN_START;

self.anim_time = (self.anim_time + 0.1);
return;
}

};
hi, I am nahuel, I love quake and qc.
User avatar
Nahuel
 
Posts: 492
Joined: Wed Jan 12, 2011 8:42 pm
Location: mar del plata

Re: Rewriting Quake's player animation code..

Postby DusterdooSmock » Wed Nov 09, 2011 2:47 am

I'm trying to get it to finish the animation if it has already been started, even if the velocity is zero.

Like this:
Code: Select all
if(self.velocity_x)
{
//existing code
}
else
{
if(self.frame > than a certain frame)
finish the animation
else
stop the animation
}


So that way if the player stops, he doesn't stop halfway through the animation.
But I've been going at it for a few hours non-stop, and I can't seem to get it to work.. :/
DusterdooSmock
 
Posts: 170
Joined: Thu Aug 19, 2010 9:58 pm

Re: Rewriting Quake's player animation code..

Postby DolphinsOfCydonia » Wed Nov 09, 2011 3:51 am

1)
You want to check the magnitude of the velocity vector, to get the speed.
Code: Select all
float s = vlen(player.velocity);
if ( s > 0)
{
// Code.
}


2)
If you inspect player.qc, you will notice that all the velocity checking happens for only the first frame. Your problem is that you're doing checking for every frame.
Code: Select all
if (self.frame == FIRST_FRAME) { // I don't know what its called OK?
// Code.
}

3)
self.anim_time = (self.anim_time + 0.1);
This is broken.
self.anim_time = time + 0.1;
Assuming that 0.1 is actually the frame increment time.
4)
Nahuel wrote:void() player_run =
{
if (self.velocity_x <= 0 )
return;
else
{
self.frame = (self.frame + 1);

if(self.frame == RUN_END)
self.frame = RUN_START;

self.anim_time = (self.anim_time + 0.1);
return;
}

};

This is also broken.
DolphinsOfCydonia
 
Posts: 21
Joined: Tue Nov 08, 2011 4:01 am

Re: Rewriting Quake's player animation code..

Postby DusterdooSmock » Wed Nov 09, 2011 4:17 am

DolphinsOfCydonia wrote:3)
self.anim_time = (self.anim_time + 0.1);
This is broken.
self.anim_time = time + 0.1;
Assuming that 0.1 is actually the frame increment time.


That solved issue #2... i think i accidentally did that when i was revising the code...
DusterdooSmock
 
Posts: 170
Joined: Thu Aug 19, 2010 9:58 pm


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest