My phyisics are wonky, please help!

B

Bicaro

Guest
So I'm creating some sort of puzzle game, and my physics should work properly. But somehow the characters can jump even tho it's no speicified in the code to do so, is the hitbox range some sort of a circle or how does it work? Take a closer look at the video clip i made. Anyways the colision is off. :(

https://gyazo.com/4b339c569d61173953542f257ff4ac24

Thus this being the code:

Code:
if(Player == 2) {
    key_left = keyboard_check(vk_left) || keyboard_check(ord('A'));
    key_right = keyboard_check(vk_right) || keyboard_check(ord('D'));
    key_jump = keyboard_check_pressed(vk_up) || keyboard_check_pressed(ord('W'));

    move = -key_left + key_right;

    if(move != 0) {
        physics_apply_force(x,y,force*move,0);
    }

    if(key_jump != 0 and (place_meeting(x,y+1,o_Solid) or place_meeting(x,y+1,o_Square) or place_meeting(x,y+1,o_Circle))) {
       physics_apply_impulse(x,y,0,jump_force);
    }
}
 
B

Bicaro

Guest
I would suggest using physics_test_overlap to do collision checks using the physics engine.

What are you trying to get him to move like?
So I want him to move like, If there is ground beneath half oh his body, so upper part of the x cant make it jump, depending on the angle.
So this helped somewhat, but now I have this problem.

https://gyazo.com/b907662d925840495152baa7cea77212

Or to at least make, so the impulse is on the part of the body where it touched the ground.
 
so you want him to climb up kind of? Why not rotate him instead?

if(keyboard_check(vk_left))
{
phy_rotation += spd;
}

you would obviously have to put some limits on that...


also, you're going to have to make sure that the physics collision isn't always on...so it isn't constantly telling you there is a floor beneath you and you can jump.
 
B

Bicaro

Guest
so you want him to climb up kind of? Why not rotate him instead?

if(keyboard_check(vk_left))
{
phy_rotation += spd;
}

you would obviously have to put some limits on that...


also, you're going to have to make sure that the physics collision isn't always on...so it isn't constantly telling you there is a floor beneath you and you can jump.
So now you gave me a good idea, I planned to make it simple, move left and right and jump, but the spinning and climbing technique seems interesting, tho i tried it your way it just starts spinning in the middle, some how we have to make an impusle at the ends to rotate or we have to change the x position of rotation. Hmmmm
 
B

Bicaro

Guest
So I want him to move like, If there is ground beneath half oh his body, so upper part of the x cant make it jump, depending on the angle.
So this helped somewhat, but now I have this problem.

https://gyazo.com/b907662d925840495152baa7cea77212

Or to at least make, so the impulse is on the part of the body where it touched the ground.
Also in this video, the rectangle was touching the side of the object, that's why made it possible to jump.
 
this code might give you some stuff to think about....
positioning, x and y...and using LOCAL impulse & force instead

key_up = keyboard_check_pressed(vk_up);
key_down = keyboard_check_pressed(vk_down);
key_left = keyboard_check_pressed(vk_left);
key_right = keyboard_check_pressed(vk_right);

if(key_right)
{
phy_rotation += 45;
physics_apply_local_impulse(x - 32, y, -3, -10);
}

if(key_left)
{
phy_rotation -= 45;
physics_apply_local_impulse(x + 32, y, 3, -10);
}
 
B

Bicaro

Guest
this code might give you some stuff to think about....
positioning, x and y...and using LOCAL impulse & force instead

key_up = keyboard_check_pressed(vk_up);
key_down = keyboard_check_pressed(vk_down);
key_left = keyboard_check_pressed(vk_left);
key_right = keyboard_check_pressed(vk_right);

if(key_right)
{
phy_rotation += 45;
physics_apply_local_impulse(x - 32, y, -3, -10);
}

if(key_left)
{
phy_rotation -= 45;
physics_apply_local_impulse(x + 32, y, 3, -10);
}
Thanks for your help but still dotn seem to make it work, gonna use the local impusle and forces to figure something out, thanks :);)
 
Top