P
Pylon
Guest
I have an object with 3 fixtures (don't know if that counts).
It has physics enabled and 0 density because I need it to stay still on screen.
I'm trying to use "physics_apply_force(x, y, 0, -15)" on "Left pressed" on it. Doesn't budge.
Is this the way things should work or am I doing something wrong? Thanks.
Edit:
I'm actually trying to drag the object around with the mouse. Also I need this object to collide with others.
The code I'm using now is this:
=============================
Create event:
grab = false;
xx = 0;
yy = 0;
_________
Step event:
if(grab==true)
{
phy_linear_velocity_x=mouse_x+xx;
phy_linear_velocity_y=mouse_y+yy;
}
_______________
Left Pressed event:
grab = true;
xx=phy_position_x-mouse_x;
yy=phy_position_y-mouse_y;
________________
Left Released event:
grab = false;
==============================
The problem with "phy_linear_velocity_x" is that once I click on the object it just goes in one direction without stopping.
Before this, I tried "phy_position_x" instead, and it works, but if I move the object too fast the other objects clip through it sometimes (like the calculations can't keep up or something).
Then, I tried "physics_apply_force" because I thought they won't clip through anymore, but that doesn't move the object at all.
I apologize, I should have been clearer from the beginning.
It has physics enabled and 0 density because I need it to stay still on screen.
I'm trying to use "physics_apply_force(x, y, 0, -15)" on "Left pressed" on it. Doesn't budge.
Is this the way things should work or am I doing something wrong? Thanks.
Edit:
I'm actually trying to drag the object around with the mouse. Also I need this object to collide with others.
The code I'm using now is this:
=============================
Create event:
grab = false;
xx = 0;
yy = 0;
_________
Step event:
if(grab==true)
{
phy_linear_velocity_x=mouse_x+xx;
phy_linear_velocity_y=mouse_y+yy;
}
_______________
Left Pressed event:
grab = true;
xx=phy_position_x-mouse_x;
yy=phy_position_y-mouse_y;
________________
Left Released event:
grab = false;
==============================
The problem with "phy_linear_velocity_x" is that once I click on the object it just goes in one direction without stopping.
Before this, I tried "phy_position_x" instead, and it works, but if I move the object too fast the other objects clip through it sometimes (like the calculations can't keep up or something).
Then, I tried "physics_apply_force" because I thought they won't clip through anymore, but that doesn't move the object at all.
I apologize, I should have been clearer from the beginning.
Last edited by a moderator: