Finding out 'what frame is the .mdl currently in?'
Moderator: InsideQC Admins
6 posts
• Page 1 of 1
Finding out 'what frame is the .mdl currently in?'
Hi all,
How can a function find out which animation frame 'self' is currently in? Specifically, I'm trying to make a touch function only trigger if the .mdl is in a specific frame.
It might be easier to explain with this simplified demonstration code:
thanks,
OneManClan
How can a function find out which animation frame 'self' is currently in? Specifically, I'm trying to make a touch function only trigger if the .mdl is in a specific frame.
It might be easier to explain with this simplified demonstration code:
- Code: Select all
PSEUDOCODE
// find the frames
$cd /quake/fortress/progs/john
// declare the frames
$frame john1 john2 john3 john4
// make functions to run the frames
void() john_frame1 = [$john1, john_frame2 ] {};
void() john_frame2 = [$john2, john_frame3 ] {};
void() john_frame3 = [$john3, john_frame4 ] {};
void() john_frame4 = [$john4, john_frame1 ] {self.nextthink = time + 20};
local entity foo;
foo = spawn();
// makes the john.mdl appear wherever the foo entity is
setmodel (foo, "progs/john.mdl");
foo.touch = Func_1;
john_frame1();
...
};
void Func_1 () =
{
// self is foo
if ( foo is currently in john_frame4)
{
// (do something)
// Q: how can Func_1 be told if we are in john_frame4?
}
};
thanks,
OneManClan
Last edited by OneManClan on Tue Jun 28, 2011 11:45 am, edited 2 times in total.
- OneManClan
- Posts: 243
- Joined: Sat Feb 28, 2009 2:38 pm
set a float equal to self.frame
It wont return the frame as $frame, but only as an integer, so you will probably have to figure out the integer value for every frame.
It wont return the frame as $frame, but only as an integer, so you will probably have to figure out the integer value for every frame.
-

behind_you - Posts: 237
- Joined: Sat Feb 05, 2011 6:57 am
- Location: Tripoli, Libya
- Code: Select all
if (self.frame == $walk5) {
// do something
}
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC
(LordHavoc)
-

frag.machine - Posts: 2090
- Joined: Sat Nov 25, 2006 1:49 pm
void() john_frame1 = [$john1, john_frame2 ] {code();};
expands to:
void() john_frame1 =
{
self.frame = $john1;
self.think = john_frame2;
self.nextthink = time+0.1;
code();
};
expands to:
void() john_frame1 =
{
self.frame = $john1;
self.think = john_frame2;
self.nextthink = time+0.1;
code();
};
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
Thanks guys.
Yes, it was self.frame all along. I got confused because there seem to be 2 different 'methods' for animation.
1. The 'Standard' way, ie described in all the QuakeC stuff I've been rtfming - Calling foo_animate1();
2. The 'Walkframe' method. Using .walkframe to time the speed of the frames, and not using any animation functions
( don't know if this is standard, or a CustomTF thing) to decide when to switch to the next $frame
Q: Is there any reason why the second method was created, and why one would choose 1 over the other? There's also a third method (that I know of) proposed by someone here in i3d recently, I'll add the link to the bottom of this thread if I find it.
Thanks Spike. This "New .mdl Frames" tutorial describes the syntax as:
.. but I've never seen 3 'arguments' in any '[ ]' section. What's the story?
OneManClan
ps. My little animation sequence is working beautifully, thanks everyone!
Yes, it was self.frame all along. I got confused because there seem to be 2 different 'methods' for animation.
1. The 'Standard' way, ie described in all the QuakeC stuff I've been rtfming - Calling foo_animate1();
- Code: Select all
// defaults to .1 frames per second, all the (required) stuff in the [...] bit can be overwritten in the {...} (code) section
void() foo_animate1 = [$foo1, foo_animate2 ] {};
void() foo_animate2 = [$foo2, foo_animate3 ] {};
etc..
2. The 'Walkframe' method. Using .walkframe to time the speed of the frames, and not using any animation functions
( don't know if this is standard, or a CustomTF thing) to decide when to switch to the next $frame
- Code: Select all
if (self.walkframe >= 8) // eg. if 8 is the number of frames
self.walkframe = 0;
self.frame = $foo1 + floor(self.walkframe);
// the 0.1 value can be manipulated to control the speed of the animation
self.walkframe = self.walkframe + 0.1;
Q: Is there any reason why the second method was created, and why one would choose 1 over the other? There's also a third method (that I know of) proposed by someone here in i3d recently, I'll add the link to the bottom of this thread if I find it.
Spike wrote:void() john_frame1 = [$john1, john_frame2 ] {code();};
expands to:
void() john_frame1 =
{
self.frame = $john1;
self.think = john_frame2;
self.nextthink = time+0.1;
code();
};
Thanks Spike. This "New .mdl Frames" tutorial describes the syntax as:
- Code: Select all
name =[framenum, nexttime, nextthink] {code};
.. but I've never seen 3 'arguments' in any '[ ]' section. What's the story?
OneManClan
ps. My little animation sequence is working beautifully, thanks everyone!
- OneManClan
- Posts: 243
- Joined: Sat Feb 28, 2009 2:38 pm
6 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest
