Body
Last updated 19 March 2017
ep_body_create_static
ep_body_create_static(world_id)
Creates a new static body.
Returns the id of the new body.
- world_id: The id of the world.
ep_body_create_dynamic
ep_body_create_dynamic(world_id, norotation)
Creates a new dynamic body.
Returns the id of the new body.
- world_id: The id of the world.
- norotation: Indicates whether the rotation of this body isn't affected by other bodies.
ep_body_destroy
ep_body_destroy(world_id, body_id)
Destroys the body.
- world_id: The id of the world.
- body_id: The id of the body.
ep_body_exists
ep_body_exists(world_id, body_id)
Returns whether the body with the given id exists.
- world_id: The id of the world.
- body_id: The id of the body.
ep_body_get_first_hingejoint
ep_body_get_first_hingejoint(world_id, body_id)
Returns the id of the first hinge joint connected to this body, or 0 if there are no hinge joints connected to this body.
- world_id: The id of the world.
- body_id: The id of the body.
ep_body_get_last_hingejoint
ep_body_get_last_hingejoint(world_id, body_id)
Returns the id of the last hinge joint connected to this body, or 0 if there are no hinge joints connected to this body.
- world_id: The id of the world.
- body_id: The id of the body.
ep_body_get_previous_hingejoint
ep_body_get_previous_hingejoint(world_id, body_id, hingejoint_id)
Returns the id of the previous hinge joint connected to this body, or 0 if there is no previous hinge joint.
- world_id: The id of the world.
- body_id: The id of the body.
- hingejoint_id: The id of the hinge joint.
ep_body_get_next_hingejoint
ep_body_get_next_hingejoint(world_id, body_id, hingejoint_id)
Returns the id of the next hinge joint connected to this body, or 0 if there is no next hinge joint.
- world_id: The id of the world.
- body_id: The id of the body.
- hingejoint_id: The id of the hinge joint.
ep_body_get_first_distancejoint
ep_body_get_first_distancejoint(world_id, body_id)
Returns the id of the first distance joint connected to this body, or 0 if there are no distance joints connected to this body.
- world_id: The id of the world.
- body_id: The id of the body.
ep_body_get_last_distancejoint
ep_body_get_last_distancejoint(world_id, body_id)
Returns the id of the last distance joint connected to this body, or 0 if there are no distance joints connected to this body.
- world_id: The id of the world.
- body_id: The id of the body.
ep_body_get_previous_distancejoint
ep_body_get_previous_distancejoint(world_id, body_id, distancejoint_id)
Returns the id of the previous distance joint connected to this body, or 0 if there is no previous distance joint.
- world_id: The id of the world.
- body_id: The id of the body.
- distancejoint_id: The id of the distance joint.
ep_body_get_next_distancejoint
ep_body_get_next_distancejoint(world_id, body_id, distancejoint_id)
Returns the id of the next distance joint connected to this body, or 0 if there is no next distance joint.
- world_id: The id of the world.
- body_id: The id of the body.
- distancejoint_id: The id of the distance joint.
ep_body_get_first_railjoint
ep_body_get_first_railjoint(world_id, body_id)
Returns the id of the first rail joint connected to this body, or 0 if there are no rail joints connected to this body.
- world_id: The id of the world.
- body_id: The id of the body.
ep_body_get_last_railjoint
ep_body_get_last_railjoint(world_id, body_id)
Returns the id of the last rail joint connected to this body, or 0 if there are no rail joints connected to this body.
- world_id: The id of the world.
- body_id: The id of the body.
ep_body_get_previous_railjoint
ep_body_get_previous_railjoint(world_id, body_id, railjoint_id)
Returns the id of the previous rail joint connected to this body, or 0 if there is no previous rail joint.
- world_id: The id of the world.
- body_id: The id of the body.
- railjoint_id: The id of the rail joint.
ep_body_get_next_railjoint
ep_body_get_next_railjoint(world_id, body_id, railjoint_id)
Returns the id of the next rail joint connected to this body, or 0 if there is no next rail joint.
- world_id: The id of the world.
- body_id: The id of the body.
- railjoint_id: The id of the rail joint.
ep_body_get_first_sliderjoint
ep_body_get_first_sliderjoint(world_id, body_id)
Returns the id of the first slider joint connected to this body, or 0 if there are no slider joints connected to this body.
- world_id: The id of the world.
- body_id: The id of the body.
ep_body_get_last_sliderjoint
ep_body_get_last_sliderjoint(world_id, body_id)
Returns the id of the last slider joint connected to this body, or 0 if there are no slider joints connected to this body.
- world_id: The id of the world.
- body_id: The id of the body.
ep_body_get_previous_sliderjoint
ep_body_get_previous_sliderjoint(world_id, body_id, sliderjoint_id)
Returns the id of the previous slider joint connected to this body, or 0 if there is no previous slider joint.
- world_id: The id of the world.
- body_id: The id of the body.
- sliderjoint_id: The id of the slider joint.
ep_body_get_next_railjoint
ep_body_get_next_railjoint(world_id, body_id, railjoint_id)
Returns the id of the next slider joint connected to this body, or 0 if there is no next slider joint.
- world_id: The id of the world.
- body_id: The id of the body.
- sliderjoint_id: The id of the slider joint.
ep_body_calculate_mass
ep_body_calculate_mass(world_id, body_id)
Calculates the center of mass, mass and moment of inertia of the body based on the shapes. Call this after creating or destroying shapes.
- world_id: The id of the world.
- body_id: The id of the body.
ep_body_set_mass
ep_body_set_mass(world_id, body_id, mass)
Changes the mass of the body.
- world_id: The id of the world.
- body_id: The id of the body.
- mass: The new mass.
ep_body_set_inertia
ep_body_set_inertia(world_id, body_id, inertia)
Changes the moment of inertia of the body
- world_id: The id of the world.
- body_id: The id of the body.
- inertia: The new moment of inertia.
ep_body_set_center
ep_body_set_center(world_id, body_id, localx, localy, updateinertia)
Changes the center of mass of the body.
- world_id: The id of the world.
- body_id: The id of the body.
- localx: The x coordinate of the new center of mass, in local coordinates.
- localy: The y coordinate of the new center of mass, in local coordinates.
- updateinertia: Indicates whether the moment of inertia should be updated (using the parallel axis theorem).
ep_body_set_position
ep_body_set_position(world_id, body_id, x, y, rot)
Changes the position of the body using the origin of the body as reference.
- world_id: The id of the world.
- body_id: The id of the body.
- x: The x coordinate of the new position.
- y: The y coordinate of the new position.
- rot: The new rotation.
ep_body_set_position_center
ep_body_set_position_center(world_id, body_id, x, y, rot)
Changes the position of the body using the center of mass of the body as reference.
- world_id: The id of the world.
- body_id: The id of the body.
- x: The x coordinate of the new position.
- y: The y coordinate of the new position.
- rot: The new rotation.
ep_body_set_position_local_point
ep_body_set_position_local_point(world_id, body_id, x, y, rot, localx, localy)
Changes the position of the body using a local point of the body as reference.
- world_id: The id of the world.
- body_id: The id of the body.
- x: The x coordinate of the new position.
- y: The y coordinate of the new position.
- rot: The new rotation.
- localx: The x coordinate of the reference point (local).
- localx: The y coordinate of the reference point (local).
ep_body_set_velocity_center
ep_body_set_velocity_center(world_id, body_id, xvel, yvel, rotvel)
Changes the velocity of the body using the center of mass of the body as reference.
- world_id: The id of the world.
- body_id: The id of the body.
- xvel: The x component of the new velocity of the body.
- yvel: The y component of the new velocity of the body.
- rotvel: The new rotational velocity of the body.
ep_body_set_velocity_local_point
ep_body_set_velocity_local_point(world_id, body_id, xvel, yvel, rotvel, localx, localy)
Changes the velocity of the body using a local point of the body as reference.
- world_id: The id of the world.
- body_id: The id of the body.
- xvel: The x component of the new velocity of the body.
- yvel: The y component of the new velocity of the body.
- rotvel: The new rotational velocity of the body.
- localx: The x coordinate of the reference point (local).
- localx: The y coordinate of the reference point (local).
ep_body_set_max_velocity
ep_body_set_max_velocity(world_id, body_id, maxvel, maxrotvel)
Changes the maximum velocity of the body.
- world_id: The id of the world.
- body_id: The id of the body.
- maxvel: The new maximum velocity. Use 0 for no limit.
- maxrotvel: The new maximum rotational velocity. Use 0 for no limit.
ep_body_set_gravity
ep_body_set_gravity(world_id, body_id, gravity_x, gravity_y)
Changes the gravity of the body, ignoring the mass.
- world_id: The id of the world.
- body_id: The id of the body.
- gravity_x: The x component of the new gravity of the body.
- gravity_y: The y component of the new gravity of the body.
ep_body_set_damping
ep_body_set_damping(world_id, body_id, damping, rotdamping)
Changes the damping factors of the body.
- world_id: The id of the world.
- body_id: The id of the body.
- damping: The new damping factor of the body.
- rotdamping: The new rotational damping factor of the body.
ep_body_store_impulses
ep_body_store_impulses(world_id, body_id, storecontactimpulses, storejointimpulses)
Changes whether impulses are stored for the body. Impulses are stored only when this setting is set to true for both bodies.
- world_id: The id of the world.
- body_id: The id of the body.
- storecontactimpulses: Indicates whether contact impulses are stored. The default value is true.
- storejointimpulses: Indicates whether joint impulses are stored. The default value is true.
ep_body_set_sleeping
ep_body_set_sleeping(world_id, body_id, sleepstable, sleepoutofview)
Changes the sleeping settings of the body. These settings are ignored if sleeping when stable or sleeping out of view is disabled for the world.
- world_id: The id of the world.
- body_id: The id of the body.
- sleepstable: Indicates whether the body should sleep when it is stable. The default value is true.
- sleepoutofview: Indicates whether the body should sleep when it is out of view. The default value is true.
ep_body_collision_test_box
ep_body_collision_test_box(world_id, body_id, w, h, x, y, rot, contact_threshold, collidemask1, collidemask2, group)
Returns the number of shapes that collide with a 'virtual' box. You can use ep_world_get_collision_shape to get the ids of the shapes.
- world_id: The id of the world.
- body_id: The id of the body.
- w: The width of the box.
- h: The height of the box.
- x: The x coordinate of the box (world coordinates).
- y: The y coordinate of the box (world coordinates).
- rot: The rotation of the box (world coordinates).
- contact_threshold: The contact threshold.
- collidemask1: The first collision mask.
- collidemask2: The second collision mask.
- group: The group. Use 0 for no group.
ep_body_collision_test_line
ep_body_collision_test_line(world_id, body_id, x1, y1, x2, y2, contact_threshold, collidemask1, collidemask2, group)
Returns the number of shapes that collide with a 'virtual' line. You can use ep_world_get_collision_shape to get the ids of the shapes.
- world_id: The id of the world.
- body_id: The id of the body.
- x1: The x coordinate of the first point (world coordinates).
- y1: The y coordinate of the first point (world coordinates).
- x2: The x coordinate of the second point (world coordinates).
- y2: The y coordinate of the second point (world coordinates).
- contact_threshold: The contact threshold.
- collidemask1: The first collision mask.
- collidemask2: The second collision mask.
- group: The group. Use 0 for no group.
ep_body_collision_test_circle
ep_body_collision_test_circle(world_id, body_id, r, x, y, contact_threshold, collidemask1, collidemask2, group)
Returns the number of shapes that collide with a 'virtual' circle. You can use ep_world_get_collision_shape to get the ids of the shapes.
- world_id: The id of the world.
- body_id: The id of the body.
- r: The radius of the circle.
- x: The x coordinate of the circle (world coordinates).
- y: The y coordinate of the circle (world coordinates).
- contact_threshold: The contact threshold.
- collidemask1: The first collision mask.
- collidemask2: The second collision mask.
- group: The group. Use 0 for no group.
ep_body_collision_test_polygon
ep_body_collision_test_polygon(world_id, body_id, polygon_id, x, y, rot, contact_threshold, collidemask1, collidemask2, group)
Returns the number of shapes that collide with a 'virtual' polygon. You can use ep_world_get_collision_shape to get the ids of the shapes.
- world_id: The id of the world.
- body_id: The id of the body.
- polygon_id: The id of the polygon.
- x: The x coordinate of the polygon (world coordinates).
- y: The x coordinate of the polygon (world coordinates).
- rot: The rotation of the polygon (world coordinates).
- contact_threshold: The contact threshold.
- collidemask1: The first collision mask.
- collidemask2: The second collision mask.
- group: The group. Use 0 for no group.
ep_body_ray_cast
ep_body_ray_cast(world_id, body_id, x, y, vx, vy, collidemask1, collidemask2, group)
Calculates whether a 'virtual' ray intersects the body. You can use ep_world_get_collision_shape to get the id of the shape.
Returns the distance to the point of intersection, or -1 if there is no intersection.
- world_id: The id of the world.
- body_id: The id of the body.
- x: The x coordinate of the starting point of the ray.
- y: The y coordinate of the starting point of the ray.
- vx: The x component of the direction vector of the ray.
- vy: The y component of the direction vector of the ray.
- collidemask1: The first collision mask.
- collidemask2: The second collision mask.
- group: The group. Use 0 for no group.
ep_body_apply_impulse
ep_body_apply_impulse(world_id, body_id, localx, localy, xforce, yforce, torque, local, ignoremass, awake)
Applies an impulse.
- world_id: The id of the world.
- body_id: The id of the body.
- localx: The x coordinate of the local point.
- localy: The y coordinate of the local point.
- xforce: The x component of the force.
- yforce: The y component of the force.
- torque: The torque.
- local: Indicates whether the force is in local coordinates (instead of world coordinates).
- ignoremass: Indicates whether the mass and moment of inertia of the body should be ignored.
- awake: Indicates whether the impulse should awake the body. If you're not sure how to use this, use true.
ep_body_apply_impulse_relative
ep_body_apply_impulse_relative(world_id, body_id, relativex, relativey, xforce, yforce, torque, ignoremass, awake)
Applies an impulse to a point relative to the center of mass.
- world_id: The id of the world.
- body_id: The id of the body.
- relativex: The x coordinate relative to the center of mass (world coordinates).
- relativey: The y coordinate relative to the center of mass (world coordinates).
- xforce: The x component of the force.
- yforce: The y component of the force.
- torque: The torque.
- ignoremass: Indicates whether the mass and moment of inertia of the body should be ignored.
- awake: Indicates whether the impulse should awake the body. If you're not sure how to use this, use true.
ep_body_get_mass
ep_body_get_mass(world_id, body_id)
Returns the mass of the body.
- world_id: The id of the world.
- body_id: The id of the body.
ep_body_get_inertia
ep_body_get_inertia(world_id, body_id)
Returns the moment of inertia of the body.
- world_id: The id of the world.
- body_id: The id of the body.
ep_body_get_center_of_mass_x
ep_body_get_center_of_mass_x(world_id, body_id)
Returns the x coordinate of the center of mass of the body (local coordinates).
- world_id: The id of the world.
- body_id: The id of the body.
ep_body_get_center_of_mass_y
ep_body_get_center_of_mass_y(world_id, body_id)
Returns the y coordinate of the center of mass of the body (local coordinates).
- world_id: The id of the world.
- body_id: The id of the body.
ep_body_get_x
ep_body_get_x(world_id, body_id)
Returns the x coordinate of the body using the origin as reference (world coordinates).
- world_id: The id of the world.
- body_id: The id of the body.
ep_body_get_y
ep_body_get_y(world_id, body_id)
Returns the y coordinate of the body using the origin as reference (world coordinates).
- world_id: The id of the world.
- body_id: The id of the body.
ep_body_get_x_center
ep_body_get_x_center(world_id, body_id)
Returns the x coordinate of the body using the center of mass as reference (world coordinates).
- world_id: The id of the world.
- body_id: The id of the body.
ep_body_get_y_center
ep_body_get_y_center(world_id, body_id)
Returns the x coordinate of the body using the center of mass as reference (world coordinates).
- world_id: The id of the world.
- body_id: The id of the body.
ep_body_get_rot
ep_body_get_rot(world_id, body_id)
Returns the rotation of the body.
- world_id: The id of the world.
- body_id: The id of the body.
ep_body_get_xvel_center
ep_body_get_xvel_center(world_id, body_id)
Returns the x velocity of the body using the center of mass as reference.
- world_id: The id of the world.
- body_id: The id of the body.
ep_body_get_yvel_center
ep_body_get_yvel_center(world_id, body_id)
Returns the y velocity of the body using the center of mass as reference.
- world_id: The id of the world.
- body_id: The id of the body.
ep_body_get_xvel_local_point
ep_body_get_xvel_local_point(world_id, body_id, localx, localy)
Returns the x coordinate of the body using a local point as reference.
- world_id: The id of the world.
- body_id: The id of the body.
- localx: The x component of the local point.
- localy: The y component of the local point.
ep_body_get_yvel_local_point
ep_body_get_yvel_local_point(world_id, body_id, localx, localy)
Returns the y coordinate of the body using a local point as reference.
- world_id: The id of the world.
- body_id: The id of the body.
- localx: The x component of the local point.
- localy: The y component of the local point.
ep_body_get_rotvel
ep_body_get_rotvel(world_id, body_id)
Returns the rotational velocity of the body.
- world_id: The id of the world.
- body_id: The id of the body.
ep_body_is_static
ep_body_is_static(world_id, body_id)
Returns whether the body is static.
- world_id: The id of the world.
- body_id: The id of the body.
ep_body_is_norotation
ep_body_is_norotation(world_id, body_id)
Returns whether the body can't rotate.
- world_id: The id of the world.
- body_id: The id of the body.
ep_body_is_sleeping
ep_body_is_sleeping(world_id, body_id)
Returns whether the body is sleeping.
- world_id: The id of the world.
- body_id: The id of the body.
ep_body_stable_timer
ep_body_stable_timer(world_id, body_id)
Returns the time this body has been stable.
- world_id: The id of the world.
- body_id: The id of the body.
ep_body_out_of_view_timer
ep_body_out_of_view_timer(world_id, body_id)
Returns the time this body has been out of view.
- world_id: The id of the world.
- body_id: The id of the body.
Coordinate and vector conversions
ep_body_coord_local_to_world_x(world_id, body_id, localx, localy)
ep_body_coord_local_to_world_y(world_id, body_id, localx, localy)
ep_body_coord_world_to_local_x(world_id, body_id, worldx, worldy)
ep_body_coord_world_to_local_y(world_id, body_id, worldx, worldy)
ep_body_vect_local_to_world_x(world_id, body_id, vx, vy)
ep_body_vect_local_to_world_y(world_id, body_id, vx, vy)
ep_body_vect_world_to_local_x(world_id, body_id, vx, vy)
ep_body_vect_world_to_local_y(world_id, body_id, vx, vy)
These functions convert between local coordinates and vectors and world coordinates and vectors.
- world_id: The id of the world.
- body_id: The id of the body.
ep_body_boxchain_begin
ep_body_boxchain_begin(world_id, body_id, vertexcount)
Begins a new box chain.
- world_id: The id of the world.
- body_id: The id of the body.
- vertexcount: The number of vertices.
ep_body_boxchain_end
ep_body_boxchain_end(world_id, body_id, circular, ignorefirstlast, width_top, width_bottom, density)
Ends the box chain and creates the box shapes.
- world_id: The id of the world.
- body_id: The id of the body.
- circular: Indicates whether this is a circular box chain.
- ignorefirstlast: Indicates whether the first and last box should be ignored. This setting is not used for circular box chains.
- width_top: The width of the top of the box chain.
- width_bottom: The width of the bottom of the box chain.
- density: The density of the boxes.
ep_body_boxchain_set_vertex
ep_body_boxchain_set_vertex(world_id, body_id, index, x, y)
Sets the coordinates of the vertex with the given index.
- world_id: The id of the world.
- body_id: The id of the body.
- index: The index (0 is the first index).
- x: The x coordinate.
- y: The x coordinate.
ep_body_boxchain_get_first
ep_body_boxchain_get_first(world_id, body_id)
Returns the id of the first shape of the box chain.
- world_id: The id of the world.
- body_id: The id of the body.
ep_body_boxchain_get_last
ep_body_boxchain_get_last(world_id, body_id)
Returns the id of the last shape of the box chain.
- world_id: The id of the world.
- body_id: The id of the body.
ep_body_previous
ep_body_previous(world_id, body_id)
Returns the id of the previous body, or 0 if there is no previous body.
- world_id: The id of the world.
- body_id: The id of the body.
ep_body_next
ep_body_next(world_id, body_id)
Returns the id of the next body, or 0 if there is no next body.
- world_id: The id of the world.
- body_id: The id of the body.
ep_body_set_uservar
ep_body_set_uservar(world_id, body_id, index, value)
Changes the value of the user variable with the given index.
- world_id: The id of the world.
- body_id: The id of the body.
- index: The index (0-4).
- value: The new value.
ep_body_get_uservar
ep_body_get_uservar(world_id, body_id, index)
Changes the value of the user variable with the given index.
- world_id: The id of the world.
- body_id: The id of the body.
- index: The index (0-4).
ep_body_first_shape
ep_body_first_shape(world_id, body_id)
Returns the id of the first shape connected to this body, or 0 if there are no shapes.
- world_id: The id of the world.
- body_id: The id of the body.
ep_body_last_shape
ep_body_last_shape(world_id, body_id)
Returns the id of the last shape connected to this body, or 0 if there are no shapes.
- world_id: The id of the world.
- body_id: The id of the body.
ep_body_shape_count
ep_body_shape_count(world_id, body_id)
Returns the number of shapes connected to this body, or 0 if there are no shapes. The body keeps track of the number of shapes internally so this function is very fast.
- world_id: The id of the world.
- body_id: The id of the body.
ep_body_first_force
ep_body_first_force(world_id, body_id)
Returns the id of the first force connected to this body, or 0 if there are no forces.
- world_id: The id of the world.
- body_id: The id of the body.
ep_body_last_force
ep_body_last_force(world_id, body_id)
Returns the id of the last force connected to this body, or 0 if there are no forces.
- world_id: The id of the world.
- body_id: The id of the body.
ep_body_force_count
ep_body_force_count(world_id, body_id)
Returns the number of forces connected to this body, or 0 if there are no forces. The body keeps track of the number of shapes internally so this function is very fast.
- world_id: The id of the world.
- body_id: The id of the body.
Comments
This page used to have a comment section. It's closed now; what remains are the questions I answered.
Luke · 1 June 2011, 20:05
whats the differents between an impulse and velocity?
Maarten Baert author · 16 June 2011, 22:03
An impulse is like a force that's applied only once. When you apply an impulse, the velocity of the body changes. You could also read the velocity yourself, modify it, and set it to the new value, but that's a lot more complicated and probably slower too.
Mgummelt · 3 July 2011, 08:25
Okay - one last question, I swear! (for now.. heh)
With regular GM movement, I can tell an object to wrap if it goes off-screen. But it seems like the bodies don't know about that setting on their object and don't wrap (meaning the objects don't wrap as their position & rotation is reset every frame to where the body is).
Can I do this with dynamic bodies?
Thanks!
-Mike
Maarten Baert author · 2 August 2011, 02:43
You can use the argument 'torque' to make the body rotate :). It's not exactly the same as rotational acceleration because it also takes the moment of inertia into account (similar to mass).
Yes, you can move the body with ep_body_set_position when it has to wrap. But ExtremePhysics doesn't know about the wrapping until it actually happens, so bodies won't collide with other bodies that are on the other side of the screen (not until one of the bodies wraps to the other side).
Platoonsgt1 · 7 January 2013, 15:26
I've encountered a problem with 'ep_body_get_rot', such as used within your big_world example.
It may be intentional, but it's vale is not restrained to '0 - 2*pi', but in fact a much larger number (I haven't tested the limit, but it's breaking my comparison between the rotation of a block, and the direction of the mouse)
I will try to work around this by subtracting 2*pi from the rotation if it gets too high, and vice-versa
Edit: Fixed it, it'll only have a problem if it's spinning faster than 2*pi degrees/step, and it'll default to braking if it gives an unusually large or small value.
Maarten Baert author · 7 January 2013, 17:56
There is no limit. This is intentional - doing otherwise would interfere with hinge joint limits.
I use this script a lot:
This solves pretty much all problems when comparing angles.
Timpossible89 · 20 April 2013, 05:35
Hye Maarten,
How to i rotate a physic body, let say a rectangular size 32x64, for example to be use as a watergate for your fluid example where i can open and close the gate by rotating the gate.
If i use GML, in object mouse event, left pressed, i can simply use "phy_rotation-=90" to rotate it to 90 degree. How do i achieve the same result with extremephysic?
Thanks!
Maarten Baert author · 20 April 2013, 17:28
You can rotate (and move) bodies with ep_body_set_position. Or the script 'physics_object_set' if you're using that. This works even for objects that are static.
Timpossible89 · 21 April 2013, 01:32
Nice, Just as i wanted. Thanks Maarten.
Hye man, is this extension can be use when target to iOS? Is it just me or it really is not supported for iOS. I run on compter, its fine. But target to iOS, the object stuck at (0,0). Please help me clarify on this.
Thanks
Maarten Baert author · 21 April 2013, 16:06
No, you can't. YYG doesn't provide any extension mechanism for iOS or Android. It works only on Windows (and Mac if you download that version, it's a bit outdated though).
Timpossible89 · 21 April 2013, 16:35
[/quote]
No, you can't. YYG doesn't provide any extension mechanism for iOS or Android. It works only on Windows (and Mac if you download that version, it's a bit outdated though).
[/quote]
I am not an expert, but other extension work fine (not physic though) on iOS. And as i notice, yours are also working fine except for your dynamic object. For static object not a problem. Only dynamic object stuck at (0,0).
Example in fluid simulation, the water are continuously being created (from water instance count) but the water stuck at (0,0). Maybe, just maybe, there is a bit of a bug with extreme physic for dynamic object that you can look at.
And as i understand YYG do provide extension mechanism for iOS. As i tested with other extensions on iOS, no problem.
So, just to let you know, if it is possible to fix anything.
By the way, this extension is awesome.
Maarten Baert author · 21 April 2013, 17:00
Sorry, there is no way ExtremePhysics can run on iOS in its current form (a DLL), even if YYG had created an extension system. I haven't heard of any DLL/dylib-based extensions that run on iOS, only extensions that are based on standard GML scripts. So yes, technically there is support for extensions, but not for extensions that actually add something to Game Maker through DLLs :).
Static objects 'work' because they don't have to do anything, so yes, they will always work even when the physics engine is completely gone :P.
In order to get this to work, you would have to:
I can't do step 2 for you, and I doubt anyone will be able to do step 1 :).
1pietras · 14 May 2013, 18:35
Is there a method that I could check if body collide with direct collision mask ?
It should working like a collision with virtual shape
Im making 2.5D game and collision mask is height of object.
Maybe there is another way to solve this problem ?
Maarten Baert author · 14 May 2013, 19:55
I'm not sure what you mean. Virtual shapes can have their own collision masks and group, so you can use them to check for collisions at a specific height in your game. Is that what you need?
1pietras · 15 May 2013, 10:33
Virtual shapes are shapes that i must create it, right ?
I have many "walls" in my game, some of them are "below" obj_player (collision mask are not matching), but i still need them to check z-coordinate landing for obj_player
And there is my question: How can i detect z_landing (collision between player_body and collision mask one level below). It is necesary to loop all obj_wall to find collision or I can get direct collision mask instantly ?
Its hard to me to explain, hope its now clear enough :)
Maarten Baert author · 15 May 2013, 19:10
You don't actually have to create virtual shapes, it's all handled by ExtremePhysics. The DLL will actually create a shape, check for collisions with that shape, and then remove the shape again. The shape doesn't have a body and is not in the list of actual shapes, so this is very fast.
There are two ways to do this. The first is simple: first try it for the higher height, and if there is no collision, go one lower and try again. Repeat this. This works fine if you have only a small number of heights (e.g. a building with a first and second floor). The second method is better if you have many different heights: set the collision masks so you can detect collisions with all heights at once, and then use a for loop to check the height of every collision that is found. Pick the one with the highest height.
Ceneka · 25 June 2013, 08:20
Hi there, can i ask you something?
I have two colliding objects ( the players), i need to know the velocity number in the exact moment at collision. Im using the fuction ep_body_get_xvel_center and ep_contact_get_point1_normalforce, but it keeps giving 0 or a constant, dont know why. Any tip?
Thank you alot.
Maarten Baert author · 23 July 2013, 20:08
Try using ep_contact_get_point1/2_normalveldelta:
Earacher · 11 August 2013, 11:18
hi maarten,could you teach me how to correct the errors of inertial? ,like trajectory correction(homing missile?),l'm stuck,can i set inertia to zero?
Maarten Baert author · 11 August 2013, 22:45
The variable 'inertia' is short for 'moment of inertia' which is something like mass but for rotations. It doesn't affect speed or direction, only rotation.
You can create homing missiles by changing the velocity. Use ep_body_get_xvel_center/ep_body_get_yvel_center to get the current velocity, convert it into a direction with point_direction, now change that direction, choose a constant speed, and convert this into a vector with lengthdir_x/lengthdir_y. Then use that as the new velocity (ep_body_set_velocity_center). Something like this:
The script 'round360':
If you want to rotate the missile as well, set 'norotation' to 'true' when you create the body (so ExtremePhysics won't rotate it for you), and add this line after the homing code:
Earacher · 15 August 2013, 09:12
hi maarten,when i set body's mass it become unstable/different even
did i made something wrong?
Maarten Baert author · 20 August 2013, 00:29
ep_body_calculate_mass doesn't return the mass, it returns 1 to indicate success or 0 for failure. It sets the mass, moment of inertia and center of mass automatically, there is no need to use ep_body_set_mass.
The simulator is probably getting unstable because you have set a mass that's far too low :).
Earacher · 24 August 2013, 07:08
hi maarten,i add
in a step event,i thought it is a Constant Force,but velocity growing larger and larger,eh,why?
Maarten Baert author · 24 August 2013, 16:24
That's what happens when you apply a constant force - it's like gravity. You can avoid this by adding damping (ep_body_set_damping).
An Average Loser · 26 October 2013, 02:23
Beginner's question:
I am making a driving game in which the player can enter and exit their vehicle. The player vehicle would be replaced by an dud object, but the real vehicle's rotation direction and speed is not reported to the dud object, spawning at a standstill and in a completely different angle. Is there any way I can correct this?
Maarten Baert author · 26 October 2013, 18:12
Sure, there are functions to get the velocity and orientation of the old body, so you can apply those to the new body so the velocity and orientation is not lost. The functions you will need are:
ep_body_get_rot
ep_body_get_xvel_center
ep_body_get_yvel_center
ep_body_get_rotvel (you didn't ask for this but I think it will be useful too)
ep_body_set_position (normally this is called by physics_object_set, it also sets the orientation)
ep_body_set_velocity_center (this sets xvel, yvel and rotvel)
An Average Loser · 27 October 2013, 00:03
I've implemented the code in the car replacement script, but it still doesn't properly orient the body. the code is below, have I done something wrong?
Maarten Baert author · 27 October 2013, 19:29
You didn't read the documentation for those functions, did you? ;)
An Average Loser · 29 October 2013, 02:58
Forgive me, i kinda just scanned it for anything relevant. Thank you for the assistance!
Maarten Baert author · 2 November 2013, 02:22
No problem :).
R3booz · 13 November 2013, 18:47
Hello
i have a problem with my top-down game, all my objects slippering around like on ice :( how can i fix that?
i use this material settings:
thank you
Maarten Baert author · 14 November 2013, 12:43
What you're looking for is called damping (ep_body_set_damping). The material settings only affect the friction between two objects.
Lukayson · 21 September 2016, 04:12
Hello, is there bigger fallout on performance, when bodies are bigger? Something like 100px*5px vs 500000px*5px ? Please, and thank you
Maarten Baert author · 21 September 2016, 21:47
For performance it doesn't matter, except for some special rare cases related to collision checking. But you may run into numerical problems if you use huge number like that. It's generally a bad idea to make objects with extreme aspect ratios. Why are you trying to do this?
Lukayson · 22 September 2016, 00:12
I am making space game with solar system (without pluto) only 3 times smaller than in real life, where 1 meter is 34 pixels. Sun is x=0 y=0. I tested EP and all its functions that I normally use, and even at pluto coordinates, it worked pretty well, same as in centre. When player want to land, bodies of rocket are teleported to one of huge boxes, where land uctually is, because planets move and rotate, and i need calm surface. I was also amazed how calm EP is, in huge speeds, i can normaly move my character in rocket , same as on ground, only now with zero gravity.
Maarten Baert author · 23 September 2016, 02:26
Haha, that's pretty amazing. I wouldn't have expected that to work that well. If you are already doing solar system scale physics, then the size of the box doesn't matter that much. The only difference is that the collision detection system may be a bit less accurate if you use very large shapes.
Lukayson · 30 June 2017, 21:23
Hello, i struggle with ep_body_set_velocity_local_point , it seem to work same as ep_body_set_velocity_center. but it does not matter what I put to local point x,y its always in center 0,0. Thank you, also thank you very much for previous help
Maarten Baert author · 1 July 2017, 20:33
What do you expect the function to do? If rotvel is zero, then ep_body_set_velocity_center and ep_body_set_velocity_local_point do the exact same thing, this is normal.