Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
1 registered members (TipmyPip), 18,513 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Animation nooobbiiee #79122
06/23/06 13:54
06/23/06 13:54
Joined: Jun 2006
Posts: 86
Asia
xboy360 Offline OP
Junior Member
xboy360  Offline OP
Junior Member

Joined: Jun 2006
Posts: 86
Asia
Hello all,
i hav been looking for Animation/Ai tutorials in diff. websites but they only show how to animate in med... i need to see how you put it in a script, using ent_animate, etc., been reading the manual but thy're just references. I need tutorials! Can anyone teach me the basics of animation in WDL?? Thx


Happy Birthday!
Re: Animation nooobbiiee [Re: xboy360] #79123
06/25/06 01:19
06/25/06 01:19
Joined: Sep 2003
Posts: 281
Arkansas\USA
raiden Offline
Member
raiden  Offline
Member

Joined: Sep 2003
Posts: 281
Arkansas\USA
Sure, I can

Ok, there is going to be quite abit more involved than just animations, because just writing an animation script does no good if you can't see it working with your character.

What we are going to do is code a player with the standard animations. We will be using cbabe as the model because she has the normal animations, stand, walk, jump, attack. We will also use what is called FSM(finite state machine) to seperate the characters animations while running. FSM will allow us to give the character behaviours so when we switch from standing to jumping, the state will change and allow the correct animation to run.

Ok, Here we go.

First we need to define our behaviour states:
Code:

define modeState = skill21;
define modeIdle = 0;
define modeWalk = 1;
define modeJump = 2;
define modeAtck = 3;


Don't let modeState confuse you, it allows you to store the current state plus switch to different states for comparison. The different modes will be compared in the player loop, and if a particular behaviour is activated, the modeState will change, and then the correct animation will play.

Next, we need some calcualtion skills:
Code:

define cycleAnims = skill22;
define animSpeed = skill23;


These will be used to calculate the animation distance and the animation speed. Notice, modestate, cycleAnims, animSpeed are entity skills, thus allowing this code to be used by multiple entities at run time.

Now for the animation function. This is the function that allows for checking what mode you are in and running the appropriate animation.
Code:

function animations() {
my.cycleAnims += my.animSpeed * time; // calculate an animation speed
if(my.modeState == modeIdle) {
ent_animate(me,"stand",my.cycleAnims,ANM_CYCLE); // animate stand
}
if(my.modeState == modeWalk) {
ent_animate(me,"walk",my.cycleAnims,ANM_CYCLE); // animate walk
}
if(my.modeState == modeJump) {
ent_animate(me,"jump",my.cycleAnims,ANM_CYCLE); // animate jump
}
if(my.modeState == modeAtck) {
ent_animate(me,"attack",my.cycleAnims,ANM_CYCLE); // animate attack
}
my.cycleAnims %= 100; // run 100% of animation, then start over
}



Look closely, you will see that the IF statements check what mode you are in, and runs the animation scene based on that mode, you can have as many or less modes as you like depending on how many different animations types your model has, and you would add those modes in this function.

Now the fun part, putting the final piece of code in that moves the player, and does the correct animations depending on your key presses.
Code:

action myPlayer {
var dist[3]; // movement distance
var maxZ = 0; // higher jump limit
var distZ = 40; // target height(can change to jump higher or lower)
my.modeState = modeIdle; // set initial state
my.animSpeed = 3; // set initial anim speed
c_setminmax(me); // reset collision hull
while(1) { // run forever
dist.x = (key_w-key_s) * 6 * time; // move distance based on w and s keys presses
trace_mode = ignore_me + ignore_passable + ignore_passents + use_box; // trace mode
dist.z = -c_trace(my.x,vector(0,0,my.z-500),trace_mode); // trace for gravity
if(dist.x != 0) { my.modeState = modeWalk; my.animSpeed = 6; } // set anim mode/speed
else { my.modeState = modeIdle; my.animSpeed = 3; } // set anim mode/speed
c_rotate(me,vector((key_a-key_d*6*time),0,0),USE_AABB); // turning, key a & d
if(mouse_left == 1 && my.cycleAnims != 0) { // attacking left mouse
my.modeState = modeAtck; // set mode
my.animSpeed = 4; // set anim speed
my.cycleAnims = 0; // reset anim cycle
while(my.cycleAnims < 99) { // run full attack anim
animations(); // animate
wait(1);
}
}
if(key_space == 1 && int(dist.z) <= 0) {
my.modestate = modeJump; // set mode
my.animSpeed = 6; // set speed
my.cycleAnims = 0; // reset anim cycle
vec_set(dist,nullvector); // reset dist vector
maxZ = my.z + distZ; // store target height
while(my.z < maxZ) { // run while your z is lower than target
dist.x = 6 * (key_w-key_s) * time; // jump forward if you press the keys
dist.y = 0; // no movement force in this direction
dist.z = 6 * time; // and move up in the air to jump
move_mode = ignore_passable + ignore_passents; // move mode
c_move(me,dist,nullvector,move_mode); // collision movement
animations(); // animate the jumping
wait(1);
}
while(my.z > (target.z-my.min_z)) { // since we are tracing down, run until z is != target
dist.x = 6 * (key_w-key_s) * time; // jump forward if you press the keys
dist.y = 0; // no movement force in this direction
dist.z = -6 * time; // and move down to the ground
trace_mode = ignore_me + ignore_passable + ignore_passents + use_box; // trace mode
c_trace(my.x,vector(0,0,my.z-1000),trace_mode); // trace while falling down
move_mode = ignore_passable + ignore_passents; // move mode
c_move(me,dist,nullvector,move_mode); // collision movement
wait(1);
}
while(my.cycleAnims < 98) { // finish off jumping animations
animations(); // animate ending jump scenes
wait(1);
}
my.cycleAnims = 0; // reset anim cycle
my.modeState = modeWalk; // reset mode
}
animations(); // animate all modes but jump
move_mode = ignore_passable + ignore_passents + glide; // move mode
c_move(me,dist,nullvector,move_mode); // collision movement
wait(1);
}
}


I am not going to go in to too much detail on this action, I have commented every line so you should have an idea what the line does, but what I wanted to show is that using states, you can create behaviour modes for your character, and depending on what you do, i.e. press the space key, press the mouse left button, press the w,a,s,d keys, you can change the mode, thus change your animation behaviour to react accordingly.

Plug the code in to your main script, attach the myPlayer action to your cbabe, and have fun, Study the code, states can be very powerful and can be used for many thing besides animations.

Happy animating

-raiden

Last edited by raiden; 06/25/06 01:55.

"It doesn't matter if we win or lose, it's how we make the game."
--------------------
Links: 3DGS for Dummies
Re: Animation nooobbiiee [Re: raiden] #79124
06/25/06 09:00
06/25/06 09:00
Joined: Jun 2006
Posts: 86
Asia
xboy360 Offline OP
Junior Member
xboy360  Offline OP
Junior Member

Joined: Jun 2006
Posts: 86
Asia
WOWW!! people are so nice here!! tnx raiden!!


Happy Birthday!
Re: Animation nooobbiiee [Re: xboy360] #79125
06/25/06 16:31
06/25/06 16:31
Joined: Jan 2004
Posts: 3,023
The Netherlands
Helghast Offline
Expert
Helghast  Offline
Expert

Joined: Jan 2004
Posts: 3,023
The Netherlands
that's a great explanation there Raiden
Grimber should file that as a small tutorial on his website, for sure!

rock on.
regards,


Formerly known as dennis_fantasy
Portfolio - http://www.designorhea.com/
Project - http://randomchance.cherrygames.org/
Re: Animation nooobbiiee [Re: Helghast] #79126
06/25/06 20:10
06/25/06 20:10
Joined: Sep 2003
Posts: 281
Arkansas\USA
raiden Offline
Member
raiden  Offline
Member

Joined: Sep 2003
Posts: 281
Arkansas\USA
Thanks for the comments . I also sent Grimber a pm about posting the tut.

-raiden


"It doesn't matter if we win or lose, it's how we make the game."
--------------------
Links: 3DGS for Dummies
Re: Animation nooobbiiee [Re: raiden] #79127
06/26/06 08:16
06/26/06 08:16
Joined: May 2006
Posts: 132
Norway
Fiskekona Offline
Member
Fiskekona  Offline
Member

Joined: May 2006
Posts: 132
Norway
I tried to run this script and got this error:
Code:
 c_rotate(me,vector((key_a-key_d*6*time),0,0),USE_AABB);               // turning, key a & d   



it says it cant recognice the USE_AABB


Programmer in training... Own GameStudio Commerical 6.50
Re: Animation nooobbiiee [Re: Fiskekona] #79128
06/26/06 10:53
06/26/06 10:53
Joined: Jun 2006
Posts: 86
Asia
xboy360 Offline OP
Junior Member
xboy360  Offline OP
Junior Member

Joined: Jun 2006
Posts: 86
Asia
hello again nice people!!

now that i know a bit about animation (tnx!), i continued studying more c-scripts. i tried making an inventory, but when it's enabled, i can still move and stuff!! I cannot move the camera by mouse ofcourse, but the arrow keys isnt disabled.is there a function or anything that lets me disable it and and enable it again? the c-script tutorial is really good, but incomplete. Sorry for being too "question-y"!! heheh


Happy Birthday!
Re: Animation nooobbiiee [Re: xboy360] #79129
06/27/06 01:48
06/27/06 01:48
Joined: Sep 2003
Posts: 281
Arkansas\USA
raiden Offline
Member
raiden  Offline
Member

Joined: Sep 2003
Posts: 281
Arkansas\USA
@Fiskekona, c_rotate only works with the latest version of wed. Replace it with:

my.pan += (key_a-key_d) * 6 * time;

Quote:


i tried making an inventory, but when it's enabled, i can still move and stuff!!




xboy360, create a variable to use as a flag to pause the movement of the player while your in the menu, like:

var inMenu = 0;

Then in your player loop, make this the first line after the while(1)
if(inMenu == 1) { wait(1); continue; }

Then in your menu code where you call it to display, add inMenu = 1;, and when you disable it, set it to 0 to unpause your movement and continue on.

-raiden


"It doesn't matter if we win or lose, it's how we make the game."
--------------------
Links: 3DGS for Dummies
Re: Animation nooobbiiee [Re: raiden] #79130
06/27/06 14:37
06/27/06 14:37
Joined: Oct 2004
Posts: 1,655
T
testDummy Offline
Serious User
testDummy  Offline
Serious User
T

Joined: Oct 2004
Posts: 1,655
Actually, I believe function c_rotate can be used in version 6.31.4, although there may be undesirable effects.
From experience, it seems parameter/variable/modifier USE_AABB is only recognized in beta versions later than 6.31.4. It doesn't appear that USE_AABB is even found in manual version 6.3, but it is found in some 6.4 versions of the manual. This suggests that it was added in 6.4 versions of 3D GameStudio.


Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1