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

GameMaker [SOLVED]Can't properly apply impulse to an instance

E

EvansBlack

Guest
So here is my code:

Code:
var ximpulse, yimpulse;
ximpulse = lengthdir_x(0.1,point_direction(phy_position_x,phy_position_y,mouse_x,mouse_y));
yimpulse = lengthdir_y(0.1,point_direction(phy_position_x,phy_position_y,mouse_x,mouse_y));
physics_apply_impulse(phy_position_x,phy_position_y,phy_position_x+ximpulse,phy_position_y+yimpulse);
It is in create event of a projectile. But this projectile when shooted have a VERY high speed and wrong angle. When i move my mouse to the left top corner (0, 0) the projectiles starts to slow down. It's like Game Maker ignores all my "phy_position_x" and "phy_position_y" and sets them to zero. Pls help!
 
E

EvansBlack

Guest
Okay, i solved the problem by myself. Here is the correct code if anyone interested:

Code:
var ximpulse, yimpulse;
ximpulse = lengthdir_x(0.5,point_direction(x,y,mouse_x,mouse_y));
yimpulse = lengthdir_y(0.5,point_direction(x,y,mouse_x,mouse_y));
physics_apply_impulse(x,y,ximpulse,yimpulse);
 
Top