#Any way to add weight to a certain point of a fixture?

11 messages · Page 1 of 1 (latest)

shadow iron
#

Lets say I have this figure and I want to make it heavier on the red spot so that it always tries to fall facing downwards, is it possible to do that?

candid stirrup
#

Wdym @shadow iron

sour harness
#

what you want to do is change the centre of mass

#

you can do that with

physics_mass_properties(mass, local_center_x, local_center_y, inertia)
shadow iron
covert mural
#

If you are not using physics you may try to use trigonometry. The "direction" works in GML using Sexagesimal degrees, that is:
0° <= θ <= 360°.
Where θ is the angle:
We know that the angle starts from cero in the X axis from the right side, increasing in value in a counterclockwise manner until it reaches 360°, when that happens the angle returns to cero.
Since the sprite is looking up by default, their angle of reference would be 90 dregrees, but in reality, their angle is cero, since that's how it was created.
I'm going to asume that what you are trying to do is to launch a missile that, when you launch it, it slowly changes its angle when falling.

Here: you launch it, the vsp is set to a negative number and y = vsp and gravity (grv) is applied every frame in vsp to add it value and by doing that you have a falling object with gravity (currently rising in altitude).
If the proyectile is not moving horizontally or is moving horizontally to the right (x >= 0)
each frame that passes in mid-air, the angle should decrease (based on the current vsp) until it reaches -90 degrees. When vsp >= 0, that is, when actually falling, the angle should decrease until it reaches -180 degrees. You should consider capping the vps values to have that max number as a reference for the angle values.
Now, if the proyectile is moving to the left (x < 0) you should increase the angles by 90° and 180° dregrees for each condition.
you can use sign(horizontal movement) as a reference for the horizontal direction the proyectile is going.

#

Damn I have time to spare. Somebody should pay me to write tutorials or something~

chrome vigil