Rewriting Quake's player animation code..
Moderator: InsideQC Admins
5 posts
• Page 1 of 1
Rewriting Quake's player animation code..
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:
In client.qc:
And finally, in player.qc:
Thanks in advance.
- Duster
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..
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;
}
};
{
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.
-

Nahuel - Posts: 492
- Joined: Wed Jan 12, 2011 8:42 pm
- Location: mar del plata
Re: Rewriting Quake's player animation code..
I'm trying to get it to finish the animation if it has already been started, even if the velocity is zero.
Like this:
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.. :/
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..
1)
You want to check the magnitude of the velocity vector, to get the speed.
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.
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)
This is also broken.
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..
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
5 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest