2 registered members (AndrewAMD, VoroneTZ),
779
guests, and 3
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: HELP! Animations
[Re: Harstad]
#248126
01/24/09 17:47
01/24/09 17:47
|
Joined: Jul 2008
Posts: 26 Norway
Harstad
OP
Newbie
|
OP
Newbie
Joined: Jul 2008
Posts: 26
Norway
|
Here's the code so far, as you can see, I'm experimenting with c-move: #include <acknex.h> #include <default.c>
VECTOR Player1_speed; ENTITY* Player1;
BMAP* mouse_point = "mouse_pointer.bmp"; BMAP* new_panel_1 = "panel_1.bmp"; BMAP* main_menu = "main_menu.bmp";
PANEL* new_panel = { pos_x = -5; pos_y = 400; layer = 1; bmap = new_panel_1; button (10,10, "Exit_button.bmp", "Exit_button_checked.bmp", "Exit_button.bmp",quit_program, NULL, NULL); flags = OVERLAY | VISIBLE; }
function mouse_toggle() { mouse_map = mouse_point; mouse_mode = 1; while (1) { mouse_pos.x = mouse_cursor.x; mouse_pos.y = mouse_cursor.y; wait (1); } }
function quit_program() { sys_exit (NULL); }
function main() { video_mode = 7; video_screen = 1; level_load ("Test_map_1.wmb"); wait (2); Player1 = ent_create ("Person.mdl", vector(-500, -100, 0), NULL); ph_setgravity (vector(0, 0, -200)); phent_settype (Player1, PH_RIGID, PH_BOX); phent_setmass (Player1,3, PH_BOX); phent_setfriction (Player1, 80); phent_setdamping (Player1, 40, 40); phent_setelasticity (Player1, 50, 20); while (1) { camera.x = Player1.x -200; camera.y = Player1.y; camera.z = Player1.z+50 ; on_m = mouse_toggle; on_q = quit_program; wait(1); } }
action move_me() { while (key_w) { c_move (Player1, nullvector, vector(0, 0, 50*time_step), GLIDE); wait (1); } }
Last edited by Harstad; 01/24/09 17:48.
|
|
|
Re: HELP! Animations
[Re: Harstad]
#248137
01/24/09 19:38
01/24/09 19:38
|
Joined: Apr 2005
Posts: 69
Goodberry
Junior Member
|
Junior Member
Joined: Apr 2005
Posts: 69
|
Hey,
If you are using physics on your player model you can't play animations on it. In order to move your character while playing a walkcycle (is that what you ar trying to do?) you would play the animation on the character and move him forward with c-move.
To do this you need to run a script on your character which updates the animation every frame. So instead of
Player1 = ent_create ("Person.mdl", vector(-500, -100, 0), NULL);
write
Player1 = ent_create ("Person.mdl", vector(-500, -100, 0), playerscript);
and then make the function playerscript like so:
void playerscript {
var anim_percentage = 0;
while(1) { anim_percentage += 2 * time_step; ent_animate(me, "walk", anim_percentage, ANM_CYCLE); c_move (Player1, nullvector, vector(0, 0, 50*time_step), GLIDE);
}
}
You should also look up the documentation for c_move in the manual, it has a complete script for moving a character.
|
|
|
Re: HELP! Animations
[Re: Harstad]
#248194
01/25/09 09:15
01/25/09 09:15
|
Joined: Oct 2008
Posts: 67
Crypton
Junior Member
|
Junior Member
Joined: Oct 2008
Posts: 67
|
if you would look up in the manual:
ent_animate(ENTITY* entity,STRING* scene,var percent,var mode)
String* scene reffers to the name of your scene. If you create frames in MED you can name them. Such as walk1 walk2 walk3 etc. That name without number is the scene string you have to use between quotes (as string is defined) For bones I'm not sure. In manual, it says kinda that you should use ANM_ADD to add animations from precalled ent_anim functions. I think in some AUM there was a tutorial about this....? Just remeber I saw one somewhere.
Cheers!
New into Gamestudio and eager to learn it.. Stuff and games done in 2D: LINK
|
|
|
Re: HELP! Animations
[Re: Harstad]
#248415
01/26/09 19:17
01/26/09 19:17
|
Joined: Jul 2008
Posts: 26 Norway
Harstad
OP
Newbie
|
OP
Newbie
Joined: Jul 2008
Posts: 26
Norway
|
Ok, so I managed to get the animations in and stuff, but I wonder, how do I get it so that when I hit w, he walks forward, but when I release it he gets to an halt with and blends into the idle animation?
function playerscript() { while(!key_w) wait(1); while(1) { ent_animate(me, "walk", anim_percentage, ANM_CYCLE); //animates the player anim_percentage += 10*time_step; // set the animation in motion c_move(me,vector(10*time_step,0, 0), nullvector, GLIDE); //sets the player in movement wait (1); } }
Last edited by Harstad; 01/26/09 19:20.
|
|
|
Re: HELP! Animations
[Re: Harstad]
#248425
01/26/09 20:09
01/26/09 20:09
|
Joined: Oct 2008
Posts: 67
Crypton
Junior Member
|
Junior Member
Joined: Oct 2008
Posts: 67
|
I'd do: //Attach it inside WED to an object:
action playerscript()
{
while(1)
{
if (key_w)
{
anim_percentage += (10*time_step)%100; //%100 keeps it inside 100 value
ent_animate(me, "walk", anim_percentage, ANM_CYCLE); //animates the player
}else{ //If no button, do the idle or stand or whatever:
idle_precentage += (5*time_step)%100; //declare a second percentage variable for this!
ent_animate(me, "idle", idle_percentage, ANM_CYCLE); //animates the player
}
c_move(me,vector(10*time_step,0, 0), nullvector, GLIDE); //sets the player in movement
wait (1);
}
}
for movement I'd do a speed variable and make it's value according to buttons: spdx = (key_w - key_a)*10*time_step; The idea is that when you press W you get (1-0)*10*time_step which is like 10*timestep. Positive value to move forward. And when A is pressed you get (0-1)*10*time which is -10*time_step a negative value to go backward f.i. And then use it inside "relvector" x component in c_move. Just go and search for tutorials. Such tricks and hints are covered there. Cheers!
New into Gamestudio and eager to learn it.. Stuff and games done in 2D: LINK
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|