M
MrJellybelly
Guest
Hey there, I'm pretty new to GML and coding in general so I've been practicing with a project and I've noticed something very strange I haven't been able to fix/understand.
My player object has various fighting moves tied to their own states and scripts. Some of the moves can only be performed on specific frames of animation and for the most part that works fine however It seems like the animations start from the frame a previous animation had ended.
So if I'm running and I press punch on frame 3, instead of the punch animation starting at frame 1, it starts from frame 3 and ends quicker than expected. Any ideas to fix this?
Here's the script I have for idle;
And here's one of my attack scripts;
I know it's a little messy but I'm still only starting out :-')
Hopefully this gives you an idea of what I'm dealing with. Thanks very much for your help!
My player object has various fighting moves tied to their own states and scripts. Some of the moves can only be performed on specific frames of animation and for the most part that works fine however It seems like the animations start from the frame a previous animation had ended.
So if I'm running and I press punch on frame 3, instead of the punch animation starting at frame 1, it starts from frame 3 and ends quicker than expected. Any ideas to fix this?
Here's the script I have for idle;
Code:
// Sprite Control
if (yprevious != y)
{
sprite_index = spr_joe_jump;
image_speed = 0;
image_index = y > yprevious;
} else {
if (xprevious != x)
{
sprite_index = spr_joe_walk;
image_speed = 0.3;
} else {
sprite_index = spr_joe_stand;
}
}
if (xprevious < x)
{
image_xscale = 1;
} else if (xprevious > x) {
image_xscale = -1;
}
if (key_down)
{
if(place_meeting(x,y+1,obj_wall))
{
state = states.duck
} else {
{
vsp = 6
}
}
}
// Attacking
if (key_attack)
{
if(place_meeting(x,y+1,obj_wall))
{
state = states.attacking;
} else {
{
state = states.airstrike;
}
}
}
// Dodge
if (key_guard)
{
if(place_meeting(x,y+1,obj_wall))
{
state = states.guard;
}
}
if (stun = 1)
{
state = states.hitstun;
}
And here's one of my attack scripts;
Code:
scr_input();
if(key_right)
{
if (hsp < .5)
{
state = states.smash
} else {
state = states.dashatk
}
}
if(key_left)
{
if (hsp > -.5)
{
state = states.smash
} else {
state = states.dashatk2
}
}
if(key_up)
{
state = states.doublejump
}
hsp = 0;
vsp = 0;
// Animation
sprite_index = spr_joe_jab;
image_speed = 0.3;
// Hitbox
if (image_index >= 3) && (image_index <=12)
{
with (instance_create(x,y,obj_joe_vulcan_hitbox))
{
image_xscale = other.image_xscale;
with (instance_place(x,y,obj_player2))
{
if (stun = 0)
{
hp -= .5;
stun = 1;
}
}
}
}
if (keyboard_check(ord("Z")))
{
if (image_index >= 9) && (image_index <=11)
{
state = states.flurry
}
}
if (stun = 1)
{
state = states.hitstun;
}
Hopefully this gives you an idea of what I'm dealing with. Thanks very much for your help!