• 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!

Legacy GM [Solved] Impulse or speed is limited

S

Seebo

Guest
Hello! I'm trying to make a game using physics. I have a cannon (obj_Cannon) which shoots balls (obj_Ball). The cannon has a small animation after which the ball is being shot. So I put this code into Animation End event of obj_Cannon:
Code:
with (instance_create(x, y, obj_Ball))
    {
    physics_apply_local_impulse(0, 0, 0, -100);
    }
It works, but if I try to change yimpulse_local to -200 or -500 or -1000 nothing changes. The impulse becomes less powerful if I write numbers between 0 and -100, but it seems that the impulse stops at 100 and doesn't become stronger.

I also disabled gravity and wrote phy_speed_y += 0.3 inside obj_Ball's Step event, maybe this has some influence on my problem.

I also found out that if I set room_speed to 60 (it was 30) the impulse could increase up to -150 but than again stops. Since room_speed is higher, my improvised gravity is stronger too. So this -150 just shoots the ball at the same level as it was at -100 with room_speed = 30. Now I think that maybe problem is not in impulse and something just limits the speed of obj_Ball.
What is wrong and how can I fix it?
 

Slyddar

Member
So obj_Ball has no code that could possibly limit speed? Have you tried it by not adjusting the gravity and using the built in one?

As a side, I've done something similar recently, shooting a ball out of a cannon. Force was a variable determined by how long the mouse button was held. Never had a problem with limits on the forces though.
Code:
var cannon_length = 40;
var inst = instance_create_layer(x+lengthdir_x(cannon_length,-phy_rotation),y+lengthdir_y(cannon_length,-phy_rotation),"bullet",o_bullet);
with(inst)
{
  physics_apply_impulse(x, y, lengthdir_x(other.force,-other.phy_rotation), lengthdir_y(other.force,-other.phy_rotation))
}
 
Last edited:

GMWolf

aka fel666
As i recall, box2D has a speed limit.
There are a couple things you should do:
Mark you objects as "bullet objects"
Increase the update speed, and update iterations.
Have a look at
Physics_world_update_iterations
Physics_world_update_speed
Phy_bullet
The manual should have you covered as to what the functions do, and how to use them.
 
S

Seebo

Guest
@TheSly No, obj_Ball has no code that affects speed except phy_speed_y += 0.3. I've tried to use the built-in gravity and it seems to work the same.
@Fel666 I added what you said and now it seems to work. I even think that now I got rid of this bug when ball went through another moving object sometimes.
Thank you all!
 
Top