#Trouble making a sprite follow the direction of a jump

18 messages · Page 1 of 1 (latest)

dire dirge
#

Changing the image angle of my sprite causes it to teleport. Does this have something to do with the placement of the origin point? For example when my character jumps (its a platformer) the model immediately teleports to the end of the platform when flipping the image angle upside down. My current assumption is that my collisions are causing this behavior as on the first frame of the jump the character model would be suddenly underground and my collision check is trying to push the character model out of the ground.

My current solution is to set image_angle to the resultant vector of point_direction(x, y, (x + hspd), (y+ vspd)) but this just causes the player object to teleport instantly.

I would like for the character model to smoothly follow the line of motion throughout the entire motion of jumping.

I do have a state machine. Im pretty sure its buns

Below is my step event for the player

charred verge
#

image_angle also rotates your collision mask, so it could be causing your collision to go haywire

#

what I suggest is not actually changing image_angle, and instead using your own custom angle variable. Then, draw the player rotated without actually rotating them so the mask stays consistent

#

can do so with draw_sprite_ext in the draw event

dire dirge
dire dirge
#

So currently it works this way but I have another problem

draw_self();

if (!hasJumped) 
{draw_text(x-30, y+10, "Can Jump");}
else if (hasJumped) 
{draw_text(x-30, y+10, "NO JUMP");}

if (state == states_new.slingAttack){
    var velocityAngle = point_direction(x, y, (x + hspd), (y +vspd));
    draw_sprite_ext(sprite_index, image_index, x, y, image_xscale, image_yscale, velocityAngle, c_white, 1);
}```

How do i do this technique without removing draw_self()?
charred verge
#

you would remove draw self and replace it with the draw_sprite_ext

#

and you could just default the angle to 0 if you're not in a state that should rotate

dire dirge
#

So this creates a situation where two sprites are drawn while in sling.attack state. Should I delete the other drawing somehow?

#

thanks for helping btw

charred verge
#

you'd get rid of draw_self

#

draw_sprite_ext is replacing it in this case

#
var velocityAngle = 0;
if (state == states_new.slingAttack){
    velocityAngle = point_direction(x, y, (x + hspd), (y +vspd));
}

draw_sprite_ext(sprite_index, image_index, x, y, image_xscale, image_yscale, velocityAngle, c_white, 1);
if (!hasJumped) 
{draw_text(x-30, y+10, "Can Jump");}
else if (hasJumped) 
{draw_text(x-30, y+10, "NO JUMP");}
``` something like this
#

so if you're not in the sling state, it goes with the default rotation of 0

#

it should look the same as using draw_self()

dire dirge
#

Ahhh you are smart guy.
thank friend this is solved