• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Windows A huge shift occurs when moving a character left and right

K

khaledzaw

Guest
Here is the code:
Create:
hsp = 0;
vsp = 0;
grv = 0;
walksp = 10;

Step:
key_left = keyboard_check(vk_left) || keyboard_check(ord("A"));
key_right = keyboard_check(vk_right) || keyboard_check(ord("D"));

//Calculate Movement
var move = key_right - key_left;

hsp = move * walksp;

vsp = vsp + grv;

//
if (place_meeting(x,y+vsp,Ground0))
{
while (!place_meeting(x,y+sign(vsp),Ground0))
{
y = y + sign(vsp);
}
vsp = 0;
}
y = y + vsp;

//Horizental Collision
x = x + hsp;

//Animation

image_speed = 1;
if (hsp == 0)
{
sprite_index = ZawS;
}
else
{
sprite_index = ZawW;
}







The Difference between the two positions showed in the .png attached to the thread is just one click.
 

Attachments

Amon

Member
What is the pivot set to in the sprite editor?

Double-click on your sprite in the Hierarchy and set the origin to middle center or bottom center.
 
K

khaledzaw

Guest
What is the pivot set to in the sprite editor?

Double-click on your sprite in the Hierarchy and set the origin to middle center or bottom center.
Thanks a bunch i feel really stupid right now. :)
 
Top