Urban Wars
August 16, 2018, 06:40:32 am
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Welcome, here you will find all the information on Urban Wars
 
  Home Help Search Staff List Login Register  

adding a new set of animation frames?

Pages: [1]
  Print  
Author Topic: adding a new set of animation frames?  (Read 44 times)
Mexicouger
Lieutenant
*
Posts: 111


View Profile
« on: April 28, 2010, 07:44:47 pm »

I want to code in a switch weapon animation so when you switch weapons, theres an animation on the one you pull out. That involves making a new function and switch case statements. However, I am basically shooting in the dark because I hav eno knowledge of anim frames. The first weapon I wanna do has 10 anim frames. Any help for setting this up?
Report Spam   Logged

Social Buttons

DukeInstinct
Administrator
Lieutenant
*****
Posts: 120


The ArchDuke


View Profile WWW
« Reply #1 on: April 28, 2010, 08:30:46 pm »

Quake does something like this (if I remember right):

Code:
void WeaponAnim1= [WeaponAnim2]{self.weaponframe=1;};
void WeaponAnim2= [WeaponAnim3]{self.weaponframe=2;};
void WeaponAnim3= [WeaponAnim4]{self.weaponframe=3;};
void WeaponAnim4= [WeaponAnim5]{self.weaponframe=4;};
void WeaponAnim5= [WeaponAnim6]{self.weaponframe=5;};
void WeaponAnim6= [WeaponAnim7]{self.weaponframe=6;};
void WeaponAnim7= [WeaponAnim8]{self.weaponframe=7;};
void WeaponAnim8= [WeaponAnim9]{self.weaponframe=8;};
void WeaponAnim9= [WeaponAnim10]{self.weaponframe=9;};
void WeaponAnim10= [IdleAnim]{self.weaponframe=10;};

And you'd just call WeaponAnim1 from the weapon firing function.

HOWEVER, you could just write a function that advances the weaponframe by 1 and is called each frame to accomplish the task of animation.

The first method is fine for animations with hardly any frames, but once you start getting weapons with up to 100 frames then you'll want to try the second method.

For UrbanWars, I use two functions. One initializes an animation (sets the start frame, and end frame, and the rate of animation) and another one which advances the current frame until it reaches the end frame.
Report Spam   Logged



Urban Wars Coder/3d Modeler/Animator

Mexicouger
Lieutenant
*
Posts: 111


View Profile
« Reply #2 on: April 28, 2010, 09:19:59 pm »

I did the first animation thing. I made a function called player_shot_throw. Then I put     

 self.weaponframe += 1;   
if (self.weaponframe >= 62)
{
pull finished();   
return;
}   
superdamagesound();   
 self.attack_finished = time + 0.2);     
self.impulse = MSG_BROADCAST; 
}; 

That is my code. I also put

startwframe (self, 51); 

 So if I want this animation to be played every time I switch weapons, where would I put it?  Would I put it in cycleweaponcommand? How do I actually view this animation in game?
« Last Edit: May 04, 2010, 09:55:08 am by Mexicouger » Report Spam   Logged
DukeInstinct
Administrator
Lieutenant
*****
Posts: 120


The ArchDuke


View Profile WWW
« Reply #3 on: April 28, 2010, 10:24:35 pm »

I don't think cycleweapon covers switching weapons via the number keys. You might have to call your weapon animation from several different functions.
Report Spam   Logged



Urban Wars Coder/3d Modeler/Animator

Mexicouger
Lieutenant
*
Posts: 111


View Profile
« Reply #4 on: April 28, 2010, 11:11:38 pm »

Well can you help me with the rest of this Duke. Im not as good a coder as you. And I learn better if I can see the code. Every code I get, I store it in my brain and use it`s pieces for stuff. I learned quite a bit about anim frames today, But I still need your help. And sorry for the jumbled code, I am on a cellphone and I can`t space
Report Spam   Logged
Pages: [1]
  Print  
 
Jump to:  


Get your own Chat Box! Go Large!
Bookmark this site! | Upgrade This Forum
SMF For Free - Create your own Forum | Buy traffic for your forum/website

Powered by SMF | SMF © 2016, Simple Machines
Privacy Policy