N
NeOp
Guest
Hi guys, got a question related do this guide:
I´m following pretty well this guide until now, i got no problems with setting up the hurtbox, but after creating the hitbox and setting up to show up the red square while attacking just to test, for some reason the hitbox only appears when i´m holding the left or right keys, basically only when my character is running, if i´m still without pressing any key and i attack, the animation plays normally but no hitbox sprite showing.
Any Ideas? The only thing i did different from the guide is the configuration of the size and position of the hurt/hitboxes, other than that, i can´t think of a reason.
GameMaker Basics: Hitboxes and Hurtboxes
Amazon Apps & Services Developer Portal
Just in case i will put my normal and attack states to help the understanding.
-------------------NORMAL STATE----------------------------------
//movement
if(left)
{
xSpeed = approach(xSpeed,-mSpeed,aSpeed);
}
else if(right)
{
xSpeed = approach(xSpeed,mSpeed,aSpeed);
}
else
{
xSpeed = approach(xSpeed,0,dSpeed);
}
//accel and decel control
if(onGround){
aSpeed = groundAccel;
dSpeed = groundDecel;
}else if(!onGround){
aSpeed = airAccel;
dSpeed = airDecel;
}
//jump
if(onGround)
{
if(jump)
{
ySpeed = jPower;
squash_stretch(0.8,1.2);
}
}
//variable jump height
if(!onGround){
if(ySpeed < 0 && !jump){
ySpeed *= 0.5;
}
}
//variable jump height
if(!onGround){
if(ySpeed < 0 && !jump){
ySpeed *= 0.5;
}
}
//don't run off the screen!
move_wrap(1,1,sprite_width);
//change to crouch state
if(down)
{
currentState = states.crouch;
squash_stretch(1.1,0.9);
}
//change to roll state
if(roll)
{
currentState = states.roll;
squash_stretch(1.2,0.8);
}
//change to attack state
if(attack)
{
currentState = states.attack;
squash_stretch(1.2,0.9);
}
//landed
if(onGround){
if(!landed){
squash_stretch(1.1,0.9); //Efeito ao aterrissar
landed = true;
}
}
if(!onGround){
landed = false;
}
--------------ATTACK STATE------------------------
frameSpeed = 0.2;
//creates the hitbox in the correct frame
if(frame == 3 && hitbox == -1)
{
hitbox = hitbox_create(25 * facing,15,25 * facing,-95,8,3 * facing,45);
}
//moving a little forward while attacking
if facing = 1
{
xSpeed = 0.5;
}
else
{
xSpeed = -0.5;
}
if(frame > sprite_get_number(sprite) - 1)
{
currentState = states.normal;
}
Appstore
Amazon Appstore Developer blog includes developers news, tutorials, and resources for building, publishing, and submitting apps and games.
developer.amazon.com
I´m following pretty well this guide until now, i got no problems with setting up the hurtbox, but after creating the hitbox and setting up to show up the red square while attacking just to test, for some reason the hitbox only appears when i´m holding the left or right keys, basically only when my character is running, if i´m still without pressing any key and i attack, the animation plays normally but no hitbox sprite showing.
Any Ideas? The only thing i did different from the guide is the configuration of the size and position of the hurt/hitboxes, other than that, i can´t think of a reason.
GameMaker Basics: Hitboxes and Hurtboxes
Amazon Apps & Services Developer Portal
Just in case i will put my normal and attack states to help the understanding.
-------------------NORMAL STATE----------------------------------
//movement
if(left)
{
xSpeed = approach(xSpeed,-mSpeed,aSpeed);
}
else if(right)
{
xSpeed = approach(xSpeed,mSpeed,aSpeed);
}
else
{
xSpeed = approach(xSpeed,0,dSpeed);
}
//accel and decel control
if(onGround){
aSpeed = groundAccel;
dSpeed = groundDecel;
}else if(!onGround){
aSpeed = airAccel;
dSpeed = airDecel;
}
//jump
if(onGround)
{
if(jump)
{
ySpeed = jPower;
squash_stretch(0.8,1.2);
}
}
//variable jump height
if(!onGround){
if(ySpeed < 0 && !jump){
ySpeed *= 0.5;
}
}
//variable jump height
if(!onGround){
if(ySpeed < 0 && !jump){
ySpeed *= 0.5;
}
}
//don't run off the screen!
move_wrap(1,1,sprite_width);
//change to crouch state
if(down)
{
currentState = states.crouch;
squash_stretch(1.1,0.9);
}
//change to roll state
if(roll)
{
currentState = states.roll;
squash_stretch(1.2,0.8);
}
//change to attack state
if(attack)
{
currentState = states.attack;
squash_stretch(1.2,0.9);
}
//landed
if(onGround){
if(!landed){
squash_stretch(1.1,0.9); //Efeito ao aterrissar
landed = true;
}
}
if(!onGround){
landed = false;
}
--------------ATTACK STATE------------------------
frameSpeed = 0.2;
//creates the hitbox in the correct frame
if(frame == 3 && hitbox == -1)
{
hitbox = hitbox_create(25 * facing,15,25 * facing,-95,8,3 * facing,45);
}
//moving a little forward while attacking
if facing = 1
{
xSpeed = 0.5;
}
else
{
xSpeed = -0.5;
}
if(frame > sprite_get_number(sprite) - 1)
{
currentState = states.normal;
}