UltraZockt
Member
Hello,
I want to create an object that bounces the player in two directions. The direction depends on where the player touches the object.
If he touches it by jumping on it he goes upwards. (like a bonus jump) and if he touches it from the bottom he gets kicked downwards.
My code looks like this so far:
Somehow if the player touches the object from the side it is a bit random if he gets kicked up or down.
Mostly its up because the player comes in from the side and that mostly counts as hitting it from the top when it clearly looks like the bottom...
Anyone has a better idea how to handle this?
I want to create an object that bounces the player in two directions. The direction depends on where the player touches the object.
If he touches it by jumping on it he goes upwards. (like a bonus jump) and if he touches it from the bottom he gets kicked downwards.
My code looks like this so far:
GML:
//in collision with object
if (place_meeting(x,y+1,o_ballon)) {
variable_jump = false;
vsp = -3.2;
}
else if (place_meeting(x,y-1,o_ballon)) {
variable_jump = false;
vsp = 0;
vsp = 1.6;
}
}
//in Step I use a very weird variable jump code. Maybe that causes some errors
//Jump
if (place_meeting(x,y+1,o_ground)) {
variable_jump = false;
on_ground = true;
jump = 1;
}
if (key_jump) && (jump > 0) {
variable_jump = true;
on_ground = false;
vsp = -3.2;
jump --;
}
//variable Jump
if (variable_jump == true) {
if (vsp < 0) && (!key_jump_held) {
vsp = max(vsp, (-3.2/4));
}
}
Mostly its up because the player comes in from the side and that mostly counts as hitting it from the top when it clearly looks like the bottom...
Anyone has a better idea how to handle this?