he program asks me the file "Extreme Physics 2.1.dat" and the download does not contain this. Is there any solution?
You probably tried to install the extension by copying the GEX file to the extensions folder. This is not the correct way to install extensions in GM. You should delete the GEX again and install it correctly. You have to install the extension using the 'Install' button in GM (Resources > Select Extensions > Install > Install). GM will ask you to select the GEX file. Select the file and GM will install the extension for you. After installing you can delete the original file (but not the files GM has created in the extension folder).
@ Omaga: Yes it would be possible to embed this physics engine into your game, and the hspeed/vspeed shouldn't cause too much of a problem. If you need just a basic examlple look at the engine example included with the engine, if you want top down physics just look for any lines of code in the create event like this:
ep_body_set_gravity(global.world,body,0,0.2);
and remove them. You would still need to slow the objects down or it will seem like it is on ice.
@ Maarten: Could you set up a PM System and allow members to start threads. That sort of system might be better than using your tutorial section for our needs... just an idea.
PERFECT PERFECT PERFECT, this is a briliant physics engine, and however extensive your tutorials are, I am not sure on one thing. I have been playing around in the engine_example and have set up a simple drawing system where you draw a shape and well, it gets created. To do this i was using your new multipoly system but the fact that you must create polygons clock-wise and they must join up defeated the purpose I had in mind, so I decided to make the new object create several line-shapes in the one body, which works perfectly but... To see the body I have to use the usedebugdraw. So, is there a way I can find all the points in a body or is there another solution.
PS. I am extremely fluent in gml but only know very minimal c++
Many thanks
Retarded Lemon
Since you created the line shapes I guess you can also remember where they are. All you need is a function to convert local coordinates to world coordinates, and there are a few functions that can do this: coordinate and vector conversions. Does this answer your question, or do you need something else?
Quote: Retarded_lemon
@ Maarten: Could you set up a PM System and allow members to start threads. That sort of system might be better than using your tutorial section for our needs... just an idea.
I'm programming this website myself so this will probably take some time, but I think it shouldn't be too hard since I've already created this comment system.
Amazing job with both the Model Creator and ExtremePhysics! Regarding the the latter: is it possible to 'rig' pre-existing sprites with an ExtremePhysics body armature to give said sprites 2D physics properties?
Amazing job with both the Model Creator and ExtremePhysics! Regarding the the latter: is it possible to 'rig' pre-existing sprites with an ExtremePhysics body armature to give said sprites 2D physics properties?
I downloaded GamerXP's program (awesome tool!) and experimented with adding polygons to sprites, but I'm still having trouble achieving the desired effect. What I'd really like to emulate is a 'soft body' effect, such that if I drop the object within whose creation event I placed the txt output from GamerXP's program [replacing sprite_index with the name of the sprite] the region of the sprite I defined with the polygon will bounce distinctly from the rest of the sprite, as if it were fatty or disconnected tissue etc. How would I go about setting up a spring/damping effect on the polygon region in order to make this work?
um i need help with your model creator how do you add textures to individual parts of the model instead of the whole model and why cant textures be put in triangles?
I need help opening the file its a dll file and it says i cant open so i went to a suggest download to help open and it still doesnt work. Ive tryed 2 diffrent programs i tried changing the file name if thats what you were trying to tell me in the tutorial non of it works...
I downloaded GamerXP's program (awesome tool!) and experimented with adding polygons to sprites, but I'm still having trouble achieving the desired effect. What I'd really like to emulate is a 'soft body' effect, such that if I drop the object within whose creation event I placed the txt output from GamerXP's program [replacing sprite_index with the name of the sprite] the region of the sprite I defined with the polygon will bounce distinctly from the rest of the sprite, as if it were fatty or disconnected tissue etc. How would I go about setting up a spring/damping effect on the polygon region in order to make this work?
Thanks,
CCJ
Things like that are very difficult to make. There's a simple soft body example in the testbed, but I don't think it's suitable for what you're trying to do. You could try using small spheres connected to springs, but I'm not sure whether this will give the effect you want.
Quote: Ash123987
I need help opening the file its a dll file and it says i cant open so i went to a suggest download to help open and it still doesnt work. Ive tryed 2 diffrent programs i tried changing the file name if thats what you were trying to tell me in the tutorial non of it works...
What are you trying to do? You don't have to open the DLL, just put it in the game directory and use the scripts ...
Quote: Eddys12
um i need help with your model creator how do you add textures to individual parts of the model instead of the whole model and why cant textures be put in triangles?
You can only use one texture per model because GM supports only one texture per model. If you need multiple textures you should either combine the textures in one image, or use multiple models.
Ah yes, one more question-- if I have a 2.5D mesh (by which I mean a flat mesh of polygons making up my model shape to create the 'fake 3d' effect) created in an external program, how would I set it up as an extreme physics body? What about for a true 3d mesh? How would I find out the various vertex coordinates of these meshes within the extreme physics world (and would I even need to)?
So far the only technique for applying physics-related animation to raster sprites that I've seen work is to cut the sprites into component parts at their 'joints' and then build an armature linking these components (this was done with IK bones in Flash and Anime Studio 7 Pro). It looks all right, but if it's not done just right the animations end up looking unnaturally stiff. I'd really like to see a technique that could rig raster sprites for predictable movement/deformation like that which can be achieved with vector sprites or 3d meshes; hopefully GamerXP's polygon program and extremephysics can help with that!
It's possible with textured primitives :).
Quote: Ccj
Ah yes, one more question-- if I have a 2.5D mesh (by which I mean a flat mesh of polygons making up my model shape to create the 'fake 3d' effect) created in an external program, how would I set it up as an extreme physics body? What about for a true 3d mesh? How would I find out the various vertex coordinates of these meshes within the extreme physics world (and would I even need to)?
Do you mean a model in GM? In that case you can't, GM doesn't have any functions to get the coordinates of vertices in a model. But if you're using a loading script you might be able to extract the coordinates.
By the way, I've added a new example about soft bodies to the testbed.
Textured primitives are basically what I'm talking about when I mention 2.5D meshes. I have a flat polygon mesh tracing of a sprite [that I did in Blender] which I then textured with the sprite's original image. Is there a way I could apply extremephysics properties to it? (Note also that I am using the Ultimate 3D 2.1 extension, which I'm fairly sure gives me the functions I need to retrieve vertex information)
Alternatively, can polygons/multipolygons created using GamerXP's program be textured like flat primitives? If I could do that the process of applying extremephysics properties to the resultant mesh would be easy since its vertex information would already be available and formatted specifically for extremephysics. Also, is there a way to convert polygons/multipolygons created for use with extremephysics into standard format meshes which could be imported into an external 3d modeling program or loaded as models within GM using ultimate 3d?
Textured primitives are basically what I'm talking about when I mention 2.5D meshes. I have a flat polygon mesh tracing of a sprite [that I did in Blender] which I then textured with the sprite's original image. Is there a way I could apply extremephysics properties to it? (Note also that I am using the Ultimate 3D 2.1 extension, which I'm fairly sure gives me the functions I need to retrieve vertex information)
Alternatively, can polygons/multipolygons created using GamerXP's program be textured like flat primitives? If I could do that the process of applying extremephysics properties to the resultant mesh would be easy since its vertex information would already be available and formatted specifically for extremephysics. Also, is there a way to convert polygons/multipolygons created for use with extremephysics into standard format meshes which could be imported into an external 3d modeling program or loaded as models within GM using ultimate 3d?
Thanks,
CCJ
If you can get the vertex data from U3D (in clockwise order), it should be possible. If you have the coordinates of the vertices you can just create a polygon (or multipolygon if the mesh is not always convex), and use that polygon/those polygons for the body. If you don't know how to use multipolygons, read this.
If you can't get the vertex data from U3D, you can also create the polygons with GamerXP's program (or any other program), use the multipolygon functions to subdivide it, use the functions to get the coordinates of vertices to copy the vertex data to an array in GM, and draw that using primitives. That's how I made the walls in my game The Machine. This is the code I used:
// subdivide the polygon
ep_world_multipoly_begin(global.world, vertices);
for(i = 0; i<vertices; i += 1) {
ep_world_multipoly_set_vertex(global.world, i, vertex_x[i], vertex_y[i]);
}
if !ep_world_multipoly_end(global.world, false) {
exit;
}
first_poly = ep_world_multipoly_get_first(global.world);
last_poly = ep_world_multipoly_get_last(global.world);
polys = last_poly-first_poly+1;
// create 3d model (for performance)
w = background_get_width(bg_tex_solid);
h = background_get_height(bg_tex_solid);
model = d3d_model_create();
for(i = 0; i<polys; i += 1) {
c = ep_polygon_get_vertex_count(global.world, first_poly+i);
d3d_model_primitive_begin(model, pr_trianglefan);
for(j = 0; j<c; j += 1) {
xx = ep_polygon_get_vertex_x(global.world, first_poly+i, j);
yy = ep_polygon_get_vertex_y(global.world, first_poly+i, j);
d3d_model_vertex_texture(model, xx-0.5, yy-0.5, 0, xx/w, yy/h);
}
d3d_model_primitive_end(model);
}
for(i = first_poly; i<=last_poly; i += 1) {
ep_polygon_destroy(global.world, i);
}
EDIT: My BBCode parser isn't working correctly (it thinks the [i] in my code is a tag), I will try to fix it :P.
If a player was standing on a block that was moving round in circles, and you wanted the player to stay on that block (as though the top of it was covered in super glue), what would be the best way to go about it?
If a player was standing on a block that was moving round in circles, and you wanted the player to stay on that block (as though the top of it was covered in super glue), what would be the best way to go about it?
Don't use ep_body_set_position to move the block, use ep_body_set_velocity_center instead. If you change the position of the body, ExtremePhysics doesn't know the block actually moved, so it can't simulate the movement correctly.
If a player was standing on a block that was moving round in circles, and you wanted the player to stay on that block (as though the top of it was covered in super glue), what would be the best way to go about it?
Don't use ep_body_set_position to move the block, use ep_body_set_velocity_center instead. If you change the position of the body, ExtremePhysics doesn't know the block actually moved, so it can't simulate the movement correctly.
I was using ep_body_set_velocity_center(), however there is not enough friction to hold the player at the correct position, I would increase friction but that then leads to the player being able to "stick" to walls. To combat that I would put in a check that only allows the player to move left/right if there is no collision, however that will prevent the player from pushing non static blocks. If I only check for static blocks then the player can still stick to a large pile of dynamic blocks. If I could remove virticle friction that would solve my problem as all dynamic blocks are set to "norotate", however I am unsure if I am able to do that.
I was using ep_body_set_velocity_center(), however there is not enough friction to hold the player at the correct position, I would increase friction but that then leads to the player being able to "stick" to walls. To combat that I would put in a check that only allows the player to move left/right if there is no collision, however that will prevent the player from pushing non static blocks. If I only check for static blocks then the player can still stick to a large pile of dynamic blocks. If I could remove virticle friction that would solve my problem as all dynamic blocks are set to "norotate", however I am unsure if I am able to do that.
Look forward to your response
Retarded Lemon
I don't think friction is the problem here, the player is probably sliding off the block because the velocity is changed in the step event. You could disable this when the player isn't touching the ground (which would be more realistic) but this would make it impossible to control the player during a jump.
You could also try to use the collision functions to check whether the player is standing on a moving block, and adjust the controls accordingly. That might work ...
I'm pretty new to using physics in games and I have a small question...
what's the difference between using forces and directly setting the velocity of an object?
if I have a character whose movement is controlled with the arrow keys, should I use forces?
Currently I am using ep_body_set_velocity_center in this way:
[...]
where movement_speed is a constant defining how fast I want the character to move in the game
Cheers
Ross
ep_body_set_velocity_center is the equivalent of motion_set. ep_body_apply_impulse is the equivalent of motion_add. Forces are equivalent to calling ep_body_apply_impulse every step.
In many situations ep_body_apply_impulse or forces are more convenient than changing the velocity manually, but if you need more precise control it might be easier to use ep_body_get_xvel_center, ep_body_get_yvel_center and ep_body_set_velocity_center.
In any case, don't use ep_body_set_position to make the character move. This won't work properly because ExtremePhysics needs the velocity to simulate collisions and joints.
I've been fiddling with EP for a little while now. You've done some great work with the engine. Stable, good performance and not too difficult to work with. Thumbs up and a big thank you for this!
However, I'd like to ask whether it would be possible to go a bit more into detail about some of the parameters in the documentation/tutorials. You know, like giving examples of practicable values for different parameters. Most of these require a lot of experimenting until you find proper values (some need to be rather smallish while others require quite big numbers in order to show any effect). I know, many depend on the size/weight of the bodies and such.. but some general examples might help here.
And the second thing is kind of a bug or something. It occured in your big-world example. When you drive that car into a corner, the wheel gets stuck there. This happened in my own project (little side-scrolling vehicle thingie.. not a game yet, just a little test to see what can be done with the engine :) ) as well. Two contacts with static bodies and you get stuck. I don't know whether somebody else has reported this yet, but I thought I'd let you know anyway.
I've been fiddling with EP for a little while now. You've done some great work with the engine. Stable, good performance and not too difficult to work with. Thumbs up and a big thank you for this!
However, I'd like to ask whether it would be possible to go a bit more into detail about some of the parameters in the documentation/tutorials. You know, like giving examples of practicable values for different parameters. Most of these require a lot of experimenting until you find proper values (some need to be rather smallish while others require quite big numbers in order to show any effect). I know, many depend on the size/weight of the bodies and such.. but some general examples might help here.
The testbed contains a lot of example values, but it's not easy to find them. What functions did you have in mind?
Quote: Dillerkind
And the second thing is kind of a bug or something. It occured in your big-world example. When you drive that car into a corner, the wheel gets stuck there. This happened in my own project (little side-scrolling vehicle thingie.. not a game yet, just a little test to see what can be done with the engine :) ) as well. Two contacts with static bodies and you get stuck. I don't know whether somebody else has reported this yet, but I thought I'd let you know anyway.
That's because the friction of the wheels was set to 20 instead of 1 (20 isn't even physically possible). I will upload a new version.
Hi Maarten!
First of all, congratulations for the awesome job you have done. I find EP relatively simple to use and I certainly would not define myself as a coder!
So, once again, thank you so much for the incredible engine you created!
I seem however not able to handle collisions properly when it comes to integrating your functions with GM's ones.
In particular, what I am trying to do, with any success so far, is the following:
I have a bullet object. It has a sprite, a body and a shape and it is dynamic. It moves using ep_body_apply_impulse_relative it receives when it is created, and it travels a straight line until he finds something. So far, everything works.
The problem is that I want the bullet to be destroyed once it collides either with enemies (dynamic bodies) and some environment objects (mostly static bodies) but I would like this event to be handled by EP and not by the Game Maker On Collision event for two reasons: first, the EP body and the bullet sprite do not coincide precisely so sometimes the body touches the other body before the sprite, resulting in a "bounce".
Second, for I want the bullet to knock enemies back according to the physics of the given world, so if I make the body smaller than the sprite and I use the On Collision event, the istance gets destroyed (setting an alarm up "desynchronizes" the physics) before the bounce(the sprite touches the other sprite before the body) and the result is no physics collision.
I think what I have not clear in my mind is how the contact and contact indexes work.
Is a contact created by two colliding bodies? From your tutorials it seems so (a contact is when the distance between two outer bodies < treshold), but then how do I store the bodies who made that contact? Does the contact index mean that index 0 = 1st contact, 1 = 2nd contact and so on?
What I have been trying so far is to use ep_world_collision_test_circle(global.world,8,x,y,0.1,1,2,3) to get the number of collisions the circle mask built on the body's shape does and then if (coll_numb > 0) {
a= ep_world_get_collision_body(global.world,0);
other functions here
}
to get the id of the body the bullet collides with so to check if its an enemy or a tree and to destroy the istance according to the case.
This results in the bullet not appearing, probabily because the bullet's body touches the gun's body when it is created (although masks and groups are set properly - I think, since the bullet do not bounce or influences the body of the gun and viceversa-), while if I use 1 as the second argument in ep_World_get_collision I get an EP error saying that the body is not colliding while the bullet is traveling towards a body.
Also, I have not been able to find a way to relate the EP body id with the GM instance ID of the body. In other words, even if I get the ID of the body, how can I tell to EP that the body I got the ID from is the body (or a mask) of an instance of a GM "obj_block_static" object? Maybe this is more of an issue with my poor coding skills but understing how GM IDs and EP IDs relate between themselves would help a lot!
Sorry for the wall of text, and thanks in advance for your help!
Hi Maarten!
First of all, congratulations for the awesome job you have done. I find EP relatively simple to use and I certainly would not define myself as a coder!
So, once again, thank you so much for the incredible engine you created!
I seem however not able to handle collisions properly when it comes to integrating your functions with GM's ones.
I think what I have not clear in my mind is how the contact and contact indexes work.
Is a contact created by two colliding bodies? From your tutorials it seems so (a contact is when the distance between two outer bodies < treshold), but then how do I store the bodies who made that contact? Does the contact index mean that index 0 = 1st contact, 1 = 2nd contact and so on?
If two bodies overlap, EP creates a contact. But a contact can have either one contact point (a point-edge collision) or two contact points (an edge-edge collision). But you don't need the contact points if you're just trying to detect collisions.
Contacts have ids just like bodies and shapes, the world has a counter to keep track of the ids. The first contact will get id 1, the next contact id 2, et cetera. But if contact 1 is destroyed, the counter stays the same, so the next contact will get id 3 even though there are only 2 contacts.
Quote: Gboy
Also, I have not been able to find a way to relate the EP body id with the GM instance ID of the body. In other words, even if I get the ID of the body, how can I tell to EP that the body I got the ID from is the body (or a mask) of an instance of a GM "obj_block_static" object? Maybe this is more of an issue with my poor coding skills but understing how GM IDs and EP IDs relate between themselves would help a lot!
The easiest way to do this is to store the id in a user variable. The tutorial shows how this works.
Hello !
I want to use the Extreme Physics for a ball game.
I tried 2 days to obtain what I want but I couldn't.
Please tell me how can I get the following result from the link below:
Hello !
I want to use the Extreme Physics for a ball game.
I tried 2 days to obtain what I want but I couldn't.
Please tell me how can I get the following result from the link below:
http://www.2shared.com/photo/X4QU8b3E/Balls.html
As you can see there the balls are aligned...
Please give me a sample.
Thank You!
That game is grid-based, ExtremePhysics isn't suitable for that kind of games. You should use a grid-based system. Did you read the official tutorial on maze games (link)?
where body1 is declared first in the same event but body2 was declared in create event of other object in room (that way both objects would be created through different objects with different sprites, and interact in a cool way.
but body2 is declared unknown.
That's because it's a local variable. You should really read a tutorial (or just the manual) about global vs. local vs. temporary variables in GM first, otherwise you will run into this kind of problems all the time :).
Quote: Jomish
I also can't get the debug draw mode to draw anything!
I was wondering in your "platform example" how you could create a hinge at the point of collision with the player and another object.
It's definitely possible. Read the tutorial on collision detection first:
http://www.maartenbaert.be/extremephysics/tutorials/collision-detection/
You can use the coordinate conversion functions to calculate the correct local coordinates. But it's not easy, and if you're new to GM you should really learn the basics first.
Quote: Dll1024
Hi
im begginer to extremePhysics. i wrote this code in key press event(spacebar) of a dynamic object:
But after a few times pressing space button, game window fills with my object color!
image_angle is in degrees, but ep_body_set_position expects radians (just like all other ExtremePhysics functions). You should use degtorad to convert it. Does this solve your problem?
Hey i'm having some trubles here i'm trying to make a dynamic Body to move towards a point like
move towards a point mouse_x and Mouse_y, But that doesnt work, i tried to apply impulse its works but i cant reach the specific point like mouse_x and mouse_y.
@Solarboy: You can get perfect 'elastic' collisions by setting 'restitution' to 1 for both shapes. So I don't think you will actually need the angle. Anyway, it doesn't work because in GM the Y axis points down, not up. So arctan2 returns incorrect results. This should work:
normal=radtodeg(arctan2(-normal_y,normal_x))
I don't know how you did the actual mirroring of the angle, but this is what I would do:
new_direction = 2*normal-old_direction;
If you did something else, that might also be the cause :).
@Matt13: I created the functions ep_world_serialize and ep_world_unserialize exactly for situations like this. Basically you have to serialize the world right before you save the game, and destroy the world right before loading the game. When the game is loaded you should create the world again and unserialize it. I have never actually tried this with the built-in saving mechanism, though. Try this:
// create event
global.world_serialize = "";
// saving:
global.world_serialize = ep_world_serialize(global.world);
game_save();
// loading:
ep_world_destroy(global.world);
game_load();
// begin step event of the object with the highest depth (the controller):
if global.world_serialize!="" {
global.world = ep_world_create();
ep_world_unserialize(global.world, global.world_serialize);
global.world_serialize = "";
}
Does this work for you?
@Gregoryogan: Try this:
var v, vx, vy, d;
v = 10; // this sets the (maximum) speed
vx = mouse_x-ep_body_get_x_center(global.world, body);
vy = mouse_y-ep_body_get_y_center(global.world, body);
d = sqrt(vx*vx+vy*vy);
if d>v {
vx *= v/d;
vy *= v/d;
}
ep_body_set_velocity_center(global.world, body, vx, vy, 0);
i wanna rotate my boxchain :) how can i do that :)
Just rotate the body.
Quote: A_d_y
Actualy how can i update boxchain points.
You can't, box chains are converted to normal box shapes when you call ep_body_boxchain_end. You have to write your own code if you want to change them afterwards.
Is there a way to create a damage system?
ex. detect collisions and their force and use the force to change the heath of the object(more force = more damage)
How do you get bodies to stop "squirming around" when piled up? I have a heap of boxes, and even with sleeping on, they don't want to stabilize.
These are my settings:
Is there a way to create a damage system?
ex. detect collisions and their force and use the force to change the heath of the object(more force = more damage)
First read the tutorial about collision detection:
http://www.maartenbaert.be/extremephysics/tutorials/collision-detection/
When you've detected a collision, you can use ep_contact_get_point1_normalveldelta and ep_contact_get_point2_normalveldelta to get the impact velocity. You can also use the impact force, but I think it will look more realistic if you use the velocity.
Quote: Drivinucrazy Games
Hey Maarten,
How do you get bodies to stop "squirming around" when piled up? I have a heap of boxes, and even with sleeping on, they don't want to stabilize.
These are my settings:
Disable sleeping and solve the stability problem first, and when that works you can try to enable sleeping again. Your values for stable_maxvel and stable_maxrotvel are way too high, that might actually make it worse. Sleeping generally doesn't make the simulation more stable, it just hides the problem :).
Try setting baumgarte_factor to 0, and make sure the coefficient of restitution of the boxes isn't too high.
Hello Maarten? I have gotten used to using your engine. But I have been getting stuck recently with adding textures to the polygons, which is the fastest way for me to add graphics to the game without using a ton of objects. I have a marker object to create the polygons at the point where I put them in the room (Like in your 'rolling_ball' example). I want to simply (If you can make it simple.) add a texture that doesn't just go on the polygons itself but loops endlessly until it reaches the bottom of the room. Similar to how you'd normally tile a room in GM. You got any ideas? Because this would really save me a lot of time and trouble.
Hello Maarten? I have gotten used to using your engine. But I have been getting stuck recently with adding textures to the polygons, which is the fastest way for me to add graphics to the game without using a ton of objects. I have a marker object to create the polygons at the point where I put them in the room (Like in your 'rolling_ball' example). I want to simply (If you can make it simple.) add a texture that doesn't just go on the polygons itself but loops endlessly until it reaches the bottom of the room. Similar to how you'd normally tile a room in GM. You got any ideas? Because this would really save me a lot of time and trouble.
If I understand your question correctly, you want to draw a polygon with a repeating texture. That's perfectly possible, just use texture_set_repeat(true); right before drawing the polygon (with draw_primitive_begin_texture). The texture coordinates should be (x/texturewidth, y/textureheight).
I forgot my old password so I created a new account, sorry. But anyways, that's exactly what I wanted but I don't know how you made the polygon and set it as a model, then added a texture to it, that confused me. I tried putting in the code you made but I got an error saying something about the vertices are greater than 3. I put 'vertices = 0' in the create and still no textures. Played around with it for a while but I still got errors. Could you explain how you made it?
hi maarteen
ı create just like a angry birds game with extreme physics but i didn't convert to html5 game
how can convert my game to html5 game help please
I forgot my old password so I created a new account, sorry. But anyways, that's exactly what I wanted but I don't know how you made the polygon and set it as a model, then added a texture to it, that confused me. I tried putting in the code you made but I got an error saying something about the vertices are greater than 3. I put 'vertices = 0' in the create and still no textures. Played around with it for a while but I still got errors. Could you explain how you made it?
Take a look at the code I posted here, it's for multipolygons but that's almost the same.
Quote: Darkness50
hi maarteen
ı create just like a angry birds game with extreme physics but i didn't convert to html5 game
how can convert my game to html5 game help please
HTML5 can't load DLLs because it runs as JavaScript. You could try to use the physics engine in GM:Studio though, but I can't help you with that (I don't have GM:Studio myself).
I've noticed that when you deactivate objects in game maker, they can get 'disconnected' from their physics bodies if the physics body is moved while the object is deactivated. I've been trying to optimize my game by deactivating objects that aren't on screen but this is proving to be a problem due to objects that are still activated pushing around the physics bodies of objects that are deactivated.
Do you have any thoughts on this or other methods to use when optimizing games that contain many physics bodies?
BTW, I am putting bodies that are off screen to sleep as well.
I've noticed that when you deactivate objects in game maker, they can get 'disconnected' from their physics bodies if the physics body is moved while the object is deactivated. I've been trying to optimize my game by deactivating objects that aren't on screen but this is proving to be a problem due to objects that are still activated pushing around the physics bodies of objects that are deactivated.
Do you have any thoughts on this or other methods to use when optimizing games that contain many physics bodies?
BTW, I am putting bodies that are off screen to sleep as well.
If possible, use the sleeping system in ExtremePhysics to make bodies that are out of view sleep (take a look at the big_world example, or the testbed test 'views'), that will save some CPU time. Then just reactivate all non-static objects every X steps (eg. 10), update all their locations (physics_object_get) and deactivate the ones that are still out of view again. It will take some processing time, but it should work (well, most of the time at least).
It would be even better if you could deactivate objects simply if the ExtremePhysics body is sleeping AND out of view, and activate them when the body stops sleeping, but I suspect you will waste more time checking the state of the bodies than you will gain.
What is the easiest way to implement wall gripping?
You could try to create a hinge joint when the body touches the wall. But it's probably a lot easier to apply a force to the body to push it against the wall.
The direction it is moving is a little more complex. I'm sure Maarten has a better way than my quick solution.
dir = point_direction(0, 0, ep_body_get_xvel_center(global.world, obj_ball_), ep_body_get_yvel_center(global.world, obj_ball_);
No, there is no easier way to do it. You're essentially converting a vector to an angle. ExtremePhysics uses vectors internally for almost anything, and I don't want to add unnecessary functions to the DLL.
Hey Maarten, I have a couple questions. Okay, I'm trying to simulate a bullet breaking a box. When the box breaks, it seperates into 4 smaller boxes equal to the size of a big box. I'm giving all the boxes health points (hp), and the bullet gets attack points (ap) based on the bullets velocity. First, I would like to know how to make the negative values of the velocity into positives, because subtracting a negative value is adding to the hp. Also maybe you could give me a couple pointers on how you think I should approach this. I want the boxes to interact with physics and also break and destroy, like if i put 2 rows of 10 boxes, the bullet can go through and break 10 boxes - if i make the bullet faster and / or give it more mass it could break all 20? Thanks again Maarten, you're a genius.
Hey Maarten, I have a couple questions. Okay, I'm trying to simulate a bullet breaking a box. When the box breaks, it seperates into 4 smaller boxes equal to the size of a big box. I'm giving all the boxes health points (hp), and the bullet gets attack points (ap) based on the bullets velocity. First, I would like to know how to make the negative values of the velocity into positives, because subtracting a negative value is adding to the hp. Also maybe you could give me a couple pointers on how you think I should approach this. I want the boxes to interact with physics and also break and destroy, like if i put 2 rows of 10 boxes, the bullet can go through and break 10 boxes - if i make the bullet faster and / or give it more mass it could break all 20? Thanks again Maarten, you're a genius.
This is a bit more complex than it sounds. ExtremePhysics has no concept of 'breaking' bodies, so if the bullet collides with the box, the bullet will simply lose all its velocity (unless it is heavy enough to move the box). That's not what you want in this case. Unfortunately there's no setting to change the maximum contact force. The closest thing I can come up with is to simply reset the velocity of the bullet to a fixed value each step. For example, the bullet starts with velocity 10 (the 'attack points'), and the velocity will be reset to 10 each step until the bullet collides with a box. At that point you can decrease the velocity to 8, for example. Each time the bullet collides with a box is slows down. If the velocity is too low, just destroy the bullet (slow bullets aren't realistic). This method is not exactly physically correct, but I expect it will look realistic enough.
PS: When you split a box into smaller boxes, don't forget to set the velocity of the new boxes to the velocity of the old box. The rotational velocity should be the same, and you can calculate the new x and y velocity with ep_body_get_xvel_local_point/ep_body_get_yvel_local_point (this will take the rotation into account). Without this, a flying box would just stop in mid-air when you shoot it.
Hey Maarten I saw your game "The Machine" and it gave me an idea for a game sort of similar. I have a question though, how did you do the drag and drop system? Thanks and great work on the Physics engine!
Hey Maarten I saw your game "The Machine" and it gave me an idea for a game sort of similar. I have a question though, how did you do the drag and drop system? Thanks and great work on the Physics engine!
Take a look at the testbed (mainly the step event of obj_controller), I used the same method there. I just added a motor to stop the rotations (same as here). Good luck :).
Hi i need some help i am trying to make a hinge joint but i can not figure out how to locate the next closest body please help!
ep_hingejoint_create(global.world,body,?,4,-8,4,8,0);
The question mark is the body_id that i want(i obviously got the first body_id).
Hi i need some help i am trying to make a hinge joint but i can not figure out how to locate the next closest body please help!
ep_hingejoint_create(global.world,body,?,4,-8,4,8,0);
The question mark is the body_id that i want(i obviously got the first body_id).
Okay, what are you trying to do? Do you want something like the testbed, where you can click and drag things with the mouse? If you want to know what bodies are at a specific position, you can use ep_world_collision_test_circle (set the radius to zero to get a point) followed by ep_world_get_collision_body.
I've been using ExtremePhysics as a big part of my game for a while now and I was thinking of moving over to GameMaker Studio for development reasons. Now, I understand you don't have Studio, and asking you not only to get it but also to figure out how to get ExtremePhysics running on there seems like a pretty ridiculous request. So I've decided to try to figure it out myself, if there is a way, although I'm not incredibly versatile with thinking about code on a scale as large as this. So I guess what I'm saying is I have some theoretical questions involving this endeavor and I was hoping you'd indulge me.
First off, the biggest hurtle. If there is no way to do this then I'll have to quite here and now. As far as I can tell, ExtremePhysics pretty thoroughly uses the function execute_string, which GMS doesn't support. Could you see any alternative methods then the use of execute_string in the cases it's used? I partially ask because I'm not quite sure why you chose to use this method in the first place. I don't mean that as some sort of passive aggressive statement by the way, I literally mean I don't understand for what reasons it would have been better to use execute_string over another method, if one existed that is.
Additionally, I've seen mentions that if it could work, the overlay would no longer be functional. Could you imagine any truth to this? Any methods the the overlay function uses that may no longer be supported?
The project I'm working on is big and I'm passionate about it. If you don't think ExtremePhysics could be modified then I'll just have to live with it. I really appreciate your time and thank you again for making ExtremePhysics in itself. I've learned almost all I know about GML while fooling around with it, so I suppose I owe you a lot.
I've been using ExtremePhysics as a big part of my game for a while now and I was thinking of moving over to GameMaker Studio for development reasons. Now, I understand you don't have Studio, and asking you not only to get it but also to figure out how to get ExtremePhysics running on there seems like a pretty ridiculous request. So I've decided to try to figure it out myself, if there is a way, although I'm not incredibly versatile with thinking about code on a scale as large as this. So I guess what I'm saying is I have some theoretical questions involving this endeavor and I was hoping you'd indulge me.
First off, the biggest hurtle. If there is no way to do this then I'll have to quite here and now. As far as I can tell, ExtremePhysics pretty thoroughly uses the function execute_string, which GMS doesn't support. Could you see any alternative methods then the use of execute_string in the cases it's used? I partially ask because I'm not quite sure why you chose to use this method in the first place. I don't mean that as some sort of passive aggressive statement by the way, I literally mean I don't understand for what reasons it would have been better to use execute_string over another method, if one existed that is.
I don't know where you got that, I never use execute_string at all! The only part of ExtremePhysics that depends on GM itself is debug drawing (using get_function_address), and that part is completely optional.
If you are wondering why the extension doesn't work in Studio, it's because of a known bug in Studio:
http://gmc.yoyogames.com/index.php?showtopic=546548
You would have to fill in the 'external name' field for each function manually in the extension editor, which takes quite some time because it can't be automated, so haven't done this. Someone else did though, you can download it here:
http://g2f.nl/0ic39bd
I haven't tested it but this one is supposed to work - on Windows, that is.
Quote: Solarboy
Additionally, I've seen mentions that if it could work, the overlay would no longer be functional. Could you imagine any truth to this? Any methods the the overlay function uses that may no longer be supported?
If you mean debug drawing, then yes, you are right. Fixing it is possible (assuming get_function_address still exists) but requires some changes to the 'GMaker' code (Delphi and C++ are quite different). It's probably not easy to do because it involves disassembling parts of the GM runner, and it's completely impossible for me since I don't have Studio. And I really don't feel like buying it since (1) I use linux almost exclusively these days, (2) I prefer C++, and (3) I don't really like some of the design decisions YYG made with Studio, especially the lack of extension support on all platforms (there's no technical reason why ExtremePhysics wouldn't run on Android and iOS except support from YYG - I've actually used ExtremePhysics on a Raspberry Pi and it worked just fine, no issues whatsoever).
Quote: Solarboy
The project I'm working on is big and I'm passionate about it. If you don't think ExtremePhysics could be modified then I'll just have to live with it.
If you can live without debug drawing and you only want to support Windows (and maybe Mac), you're fine. Otherwise you could try the built-in physics engine (I have no idea whether that one has debug drawing though, and there were some resource leak issues I've heard).
Quote: Solarboy
I really appreciate your time and thank you again for making ExtremePhysics in itself. I've learned almost all I know about GML while fooling around with it, so I suppose I owe you a lot.
one of your example requiring an older extreme physic extension.can you upgrade the example to use extrem physic 2.2 or i must use the both of extreme physic?
thanks for your answer
PS.:sorry for my bad english.im from indonesian
btw.what is your facebook account? add me:https://www.facebook.com/hilmyfarhannn?ref=tn_tnmn
my email:*****
one of your example requiring an older extreme physic extension.can you upgrade the example to use extrem physic 2.2 or i must use the both of extreme physic?
thanks for your answer
PS.:sorry for my bad english.im from indonesian
btw.what is your facebook account? add me:https://www.facebook.com/hilmyfarhannn?ref=tn_tnmn
my email:*****
Which example? I recently added a few examples that weren't included by default, and I forgot to update them, but now I'm not even sure which ones they were. These ones are probably outdated:
- collision_sounds
- collision_sparks
- orientation_follows_direction
Was it one of those?
PS: I don't use facebook, but you can mail me if you want :). My address is in LICENSE.txt (you shouldn't post email addresses in plain text, spam bots will find them).
I'm not sure where to post this, so sorry if this is the wrong section.
I just installed EP and now I'm starting to check the examples.
I know this is a noob question, but, what's the purpose of draw_sprite_corrected()? I mean, why do you have to make a correction to x and y?
Sorry for my english, and Thank you very much for EP.
That's because the function draw_sprite_ext is buggy. If you rotate a sprite 180 degrees, you will see that it is drawn in the wrong location (shifted by one pixel). draw_sprite_corrected moves the sprite back in the opposite direction to fix this bug.
Hi, I'm a bit curious when I saw that you created a physics engine in C++ for GameMaker when I was searching up physics engines. I'm trying to create a game on GameMaker, and I want to build a custom engine. How would you use another programming language on GameMaker? And would it be worth it to do that instead of just making one in GML?
Hi, I'm a bit curious when I saw that you created a physics engine in C++ for GameMaker when I was searching up physics engines. I'm trying to create a game on GameMaker, and I want to build a custom engine. How would you use another programming language on GameMaker? And would it be worth it to do that instead of just making one in GML?
A long time ago I wrote a tutorial about creating your own (simple) physics engine in GM. It uses GML but the theory applies to any programming language. You can read it here: http://www.game-maker.nl/forums/topic,53515
The text is in Dutch, but you can still use the examples. They should be pretty easy to understand, because they gradually become more complex, with each example adding one more feature to the previous one.
How do I make the ball bounce higher than what it is.(using the rolling ball example)
I do not want to change the gravity.Also how do I make the ball jump in the direction of normal of the contact body?
Im currently changing the normalvelocity to something else and quickly changing it back to 0 to jump. Is there any better way to do this?
How do I make the ball bounce higher than what it is.(using the rolling ball example)
I do not want to change the gravity.Also how do I make the ball jump in the direction of normal of the contact body?
Im currently changing the normalvelocity to something else and quickly changing it back to 0 to jump. Is there any better way to do this?
If you want the ball to jump away from whatever it is touching, you can use ep_shape_set_material to temporarily change the normal velocity of the ball to a positive value. This should produce the effect you want.
How do I make the ball bounce higher than what it is.(using the rolling ball example)
I do not want to change the gravity.Also how do I make the ball jump in the direction of normal of the contact body?
Im currently changing the normalvelocity to something else and quickly changing it back to 0 to jump. Is there any better way to do this?
If you want the ball to jump away from whatever it is touching, you can use ep_shape_set_material to temporarily change the normal velocity of the ball to a positive value. This should produce the effect you want.
Thanks. But now im facing another problem.
How do I make the ball roll up surfaces without having to run-back-then-run-forward-with-enough-speed roll up. The ball gets stuck spinning between the floor and the ramp.
The ball gets stuck in this position.
O
/ / O/ /-------
____O/. The ball should roll up like this ____O/. ____/. ____/.
How do I make the ball bounce higher than what it is.(using the rolling ball example)
I do not want to change the gravity.Also how do I make the ball jump in the direction of normal of the contact body?
Im currently changing the normalvelocity to something else and quickly changing it back to 0 to jump. Is there any better way to do this?
If you want the ball to jump away from whatever it is touching, you can use ep_shape_set_material to temporarily change the normal velocity of the ball to a positive value. This should produce the effect you want.
Thanks. But now im facing another problem.
How do I make the ball roll up surfaces without having to run-back-then-run-forward-with-enough-speed roll up. The ball gets stuck spinning between the floor and the ramp.
The ball gets stuck in this position.
O
/ / O/ /-------
____O/. The ball should roll up like this ____O/. ____/. ____/.
You can avoid this by reducing the coefficient of friction of the ball. If that doesn't work, please show me a screenshot or video, I'm not sure whether I understand your problem correctly.
How do I make the ball bounce higher than what it is.(using the rolling ball example)
I do not want to change the gravity.Also how do I make the ball jump in the direction of normal of the contact body?
Im currently changing the normalvelocity to something else and quickly changing it back to 0 to jump. Is there any better way to do this?
If you want the ball to jump away from whatever it is touching, you can use ep_shape_set_material to temporarily change the normal velocity of the ball to a positive value. This should produce the effect you want.
Thanks. But now im facing another problem.
How do I make the ball roll up surfaces without having to run-back-then-run-forward-with-enough-speed roll up. The ball gets stuck spinning between the floor and the ramp.
The ball gets stuck in this position.
O
/ / O/ /-------
____O/. The ball should roll up like this ____O/. ____/. ____/.
You can avoid this by reducing the coefficient of friction of the ball. If that doesn't work, please show me a screenshot or video, I'm not sure whether I understand your problem correctly.
This happens http://imgur.com/1kHRihI
Also the bouncy effect thingy is intentional
This happens http://imgur.com/1kHRihI
Also the bouncy effect thingy is intentional
The ball isn't stuck, it just doesn't have enough traction to roll up a 45 degree slope. In that case the coefficient of friction is too low. If you want to maintain traction on steep slopes like that, you need a coefficient of friction higher than 1, but that will get you stuck in 90 degree corners.
The easiest option is to just redesign your levels so they don't use 45 degree slopes in places where the player can't get enough speed to roll or jump up.
Hello there Maarten. Maybe you don't even check this page anymore and surely you don't got time to answer questions about this extension anymore.
Thing is i'm running through a lot of old (2011 Era) Game Maker 8-8.1 Projects and most of them did use the ExtremePhysics 2.1. But thing is all of them suddenly have kinda "transparent" collisions. I mean things don't even collide anymore. But the extension is properly installed since things like apply forces and gravity still working. I did check the code line by line and compared it to the examples include in that version.
Surprisingly the examples work properly but all the different versions which they were working have this absence of collisions.
Can be caused by the difference in the OS Since now its executing in a Windows 10 Pro?. If its possible I would try to play/edit/compile them in a Win7 Virtualization.
Anyways thanks for your time. Your extension gave me a lot of funny hours a long time ago!.
Hello there Maarten. Maybe you don't even check this page anymore and surely you don't got time to answer questions about this extension anymore.
Thing is i'm running through a lot of old (2011 Era) Game Maker 8-8.1 Projects and most of them did use the ExtremePhysics 2.1. But thing is all of them suddenly have kinda "transparent" collisions. I mean things don't even collide anymore. But the extension is properly installed since things like apply forces and gravity still working. I did check the code line by line and compared it to the examples include in that version.
Surprisingly the examples work properly but all the different versions which they were working have this absence of collisions.
Can be caused by the difference in the OS Since now its executing in a Windows 10 Pro?. If its possible I would try to play/edit/compile them in a Win7 Virtualization.
Anyways thanks for your time. Your extension gave me a lot of funny hours a long time ago!.
Missing collisions specifically can be caused by failing to call ep_world_update_contacts before ep_world_simulate_step. IIRC in some older versions of ExtremePhysics there was no ep_world_update_contacts and the collision processing was done in ep_world_simulate_step.
If that doesn't help: Are you using the DLL+scripts, or the GEX extension? Normally I would recommend the GEX for performance reasons, however I think some examples use the DLL+scripts because that made development easier for me (no need to create a new extension every time I made a change to the code). So that might explain why the examples work while your own projects don't.
Windows has some options for running software in Windows 7 compatibility mode, this might help.
Comments
This page used to have a comment section. It's closed now; what remains are the questions I answered.
Tenkeral · 23 June 2010, 10:53
he program asks me the file "Extreme Physics 2.1.dat" and the download does not contain this. Is there any solution?
Maarten Baert author · 23 June 2010, 16:23
You probably tried to install the extension by copying the GEX file to the extensions folder. This is not the correct way to install extensions in GM. You should delete the GEX again and install it correctly. You have to install the extension using the 'Install' button in GM (Resources > Select Extensions > Install > Install). GM will ask you to select the GEX file. Select the file and GM will install the extension for you. After installing you can delete the original file (but not the files GM has created in the extension folder).
Retarded_lemon · 9 August 2010, 01:35
@ Omaga: Yes it would be possible to embed this physics engine into your game, and the hspeed/vspeed shouldn't cause too much of a problem. If you need just a basic examlple look at the engine example included with the engine, if you want top down physics just look for any lines of code in the create event like this:
ep_body_set_gravity(global.world,body,0,0.2);
and remove them. You would still need to slow the objects down or it will seem like it is on ice.
@ Maarten: Could you set up a PM System and allow members to start threads. That sort of system might be better than using your tutorial section for our needs... just an idea.
Maarten Baert author · 10 August 2010, 20:26
Since you created the line shapes I guess you can also remember where they are. All you need is a function to convert local coordinates to world coordinates, and there are a few functions that can do this: coordinate and vector conversions. Does this answer your question, or do you need something else?
I'm programming this website myself so this will probably take some time, but I think it shouldn't be too hard since I've already created this comment system.
Ccj · 17 August 2010, 17:18
Hello Maarten,
Amazing job with both the Model Creator and ExtremePhysics! Regarding the the latter: is it possible to 'rig' pre-existing sprites with an ExtremePhysics body armature to give said sprites 2D physics properties?
Maarten Baert author · 19 August 2010, 14:28
Sure, you can use polygons to do that. GamerXP has made a program that generates code for polygons. You can download it here:
http://sprites.3dn.ru/Uploads/Files/PolygonCreator.rar
Ccj · 26 August 2010, 08:26
I downloaded GamerXP's program (awesome tool!) and experimented with adding polygons to sprites, but I'm still having trouble achieving the desired effect. What I'd really like to emulate is a 'soft body' effect, such that if I drop the object within whose creation event I placed the txt output from GamerXP's program [replacing sprite_index with the name of the sprite] the region of the sprite I defined with the polygon will bounce distinctly from the rest of the sprite, as if it were fatty or disconnected tissue etc. How would I go about setting up a spring/damping effect on the polygon region in order to make this work?
Thanks,
CCJ
Eddys12 · 27 August 2010, 15:12
um i need help with your model creator how do you add textures to individual parts of the model instead of the whole model and why cant textures be put in triangles?
Ash123987 · 30 August 2010, 21:19
I need help opening the file its a dll file and it says i cant open so i went to a suggest download to help open and it still doesnt work. Ive tryed 2 diffrent programs i tried changing the file name if thats what you were trying to tell me in the tutorial non of it works...
Maarten Baert author · 1 September 2010, 18:11
Things like that are very difficult to make. There's a simple soft body example in the testbed, but I don't think it's suitable for what you're trying to do. You could try using small spheres connected to springs, but I'm not sure whether this will give the effect you want.
What are you trying to do? You don't have to open the DLL, just put it in the game directory and use the scripts ...
You can only use one texture per model because GM supports only one texture per model. If you need multiple textures you should either combine the textures in one image, or use multiple models.
Ccj · 10 September 2010, 23:23
Ah yes, one more question-- if I have a 2.5D mesh (by which I mean a flat mesh of polygons making up my model shape to create the 'fake 3d' effect) created in an external program, how would I set it up as an extreme physics body? What about for a true 3d mesh? How would I find out the various vertex coordinates of these meshes within the extreme physics world (and would I even need to)?
Thanks,
CCJ
Maarten Baert author · 12 September 2010, 18:09
It's possible with textured primitives :).
Do you mean a model in GM? In that case you can't, GM doesn't have any functions to get the coordinates of vertices in a model. But if you're using a loading script you might be able to extract the coordinates.
By the way, I've added a new example about soft bodies to the testbed.
Ccj · 16 September 2010, 21:21
Textured primitives are basically what I'm talking about when I mention 2.5D meshes. I have a flat polygon mesh tracing of a sprite [that I did in Blender] which I then textured with the sprite's original image. Is there a way I could apply extremephysics properties to it? (Note also that I am using the Ultimate 3D 2.1 extension, which I'm fairly sure gives me the functions I need to retrieve vertex information)
Alternatively, can polygons/multipolygons created using GamerXP's program be textured like flat primitives? If I could do that the process of applying extremephysics properties to the resultant mesh would be easy since its vertex information would already be available and formatted specifically for extremephysics. Also, is there a way to convert polygons/multipolygons created for use with extremephysics into standard format meshes which could be imported into an external 3d modeling program or loaded as models within GM using ultimate 3d?
Thanks,
CCJ
Maarten Baert author · 17 September 2010, 21:45
If you can get the vertex data from U3D (in clockwise order), it should be possible. If you have the coordinates of the vertices you can just create a polygon (or multipolygon if the mesh is not always convex), and use that polygon/those polygons for the body. If you don't know how to use multipolygons, read this.
If you can't get the vertex data from U3D, you can also create the polygons with GamerXP's program (or any other program), use the multipolygon functions to subdivide it, use the functions to get the coordinates of vertices to copy the vertex data to an array in GM, and draw that using primitives. That's how I made the walls in my game The Machine. This is the code I used:
EDIT: My BBCode parser isn't working correctly (it thinks the [i] in my code is a tag), I will try to fix it :P.
EDIT 2: Fixed.
Retarded_lemon · 30 November 2010, 21:35
If a player was standing on a block that was moving round in circles, and you wanted the player to stay on that block (as though the top of it was covered in super glue), what would be the best way to go about it?
Thanks
Retarded Lemon
Maarten Baert author · 10 December 2010, 20:30
Don't use ep_body_set_position to move the block, use ep_body_set_velocity_center instead. If you change the position of the body, ExtremePhysics doesn't know the block actually moved, so it can't simulate the movement correctly.
Retarded_lemon · 11 December 2010, 01:38
I was using ep_body_set_velocity_center(), however there is not enough friction to hold the player at the correct position, I would increase friction but that then leads to the player being able to "stick" to walls. To combat that I would put in a check that only allows the player to move left/right if there is no collision, however that will prevent the player from pushing non static blocks. If I only check for static blocks then the player can still stick to a large pile of dynamic blocks. If I could remove virticle friction that would solve my problem as all dynamic blocks are set to "norotate", however I am unsure if I am able to do that.
Look forward to your response
Retarded Lemon
Maarten Baert author · 14 December 2010, 18:49
I don't think friction is the problem here, the player is probably sliding off the block because the velocity is changed in the step event. You could disable this when the player isn't touching the ground (which would be more realistic) but this would make it impossible to control the player during a jump.
You could also try to use the collision functions to check whether the player is standing on a moving block, and adjust the controls accordingly. That might work ...
Johnmenez · 21 January 2011, 00:37
This is what i'm looking for. Nice work. However, I have a question, how do I detect collision in ray casting?
Maarten Baert author · 25 January 2011, 18:11
ep_world_ray_cast returns -1 if there is no collision. If the return value is any other number, there is a collision.
Ross93 · 2 March 2011, 03:05
Hey there
I'm pretty new to using physics in games and I have a small question...
what's the difference between using forces and directly setting the velocity of an object?
if I have a character whose movement is controlled with the arrow keys, should I use forces?
Currently I am using ep_body_set_velocity_center in this way:
where movement_speed is a constant defining how fast I want the character to move in the game
Cheers
Ross
Maarten Baert author · 5 March 2011, 19:08
ep_body_set_velocity_center is the equivalent of motion_set. ep_body_apply_impulse is the equivalent of motion_add. Forces are equivalent to calling ep_body_apply_impulse every step.
In many situations ep_body_apply_impulse or forces are more convenient than changing the velocity manually, but if you need more precise control it might be easier to use ep_body_get_xvel_center, ep_body_get_yvel_center and ep_body_set_velocity_center.
In any case, don't use ep_body_set_position to make the character move. This won't work properly because ExtremePhysics needs the velocity to simulate collisions and joints.
Dillerkind · 10 March 2011, 13:30
Hey Maarten..
I've been fiddling with EP for a little while now. You've done some great work with the engine. Stable, good performance and not too difficult to work with. Thumbs up and a big thank you for this!
However, I'd like to ask whether it would be possible to go a bit more into detail about some of the parameters in the documentation/tutorials. You know, like giving examples of practicable values for different parameters. Most of these require a lot of experimenting until you find proper values (some need to be rather smallish while others require quite big numbers in order to show any effect). I know, many depend on the size/weight of the bodies and such.. but some general examples might help here.
And the second thing is kind of a bug or something. It occured in your big-world example. When you drive that car into a corner, the wheel gets stuck there. This happened in my own project (little side-scrolling vehicle thingie.. not a game yet, just a little test to see what can be done with the engine :) ) as well. Two contacts with static bodies and you get stuck. I don't know whether somebody else has reported this yet, but I thought I'd let you know anyway.
Maarten Baert author · 15 March 2011, 20:35
The testbed contains a lot of example values, but it's not easy to find them. What functions did you have in mind?
That's because the friction of the wheels was set to 20 instead of 1 (20 isn't even physically possible). I will upload a new version.
Johnmenez · 28 March 2011, 10:12
In your game, "the machine", the metal rods with many holes,(i don't know what it is) how do you drag the rods and rotate towards the mouse?
Maarten Baert author · 30 March 2011, 14:41
I used hinge joints to do that. There's an example that shows how it's done: picking_up_boxes.gmk (part of the ExtremePhysics ZIP file).
Gboy · 24 May 2011, 15:38
Hi Maarten!
First of all, congratulations for the awesome job you have done. I find EP relatively simple to use and I certainly would not define myself as a coder!
So, once again, thank you so much for the incredible engine you created!
I seem however not able to handle collisions properly when it comes to integrating your functions with GM's ones.
In particular, what I am trying to do, with any success so far, is the following:
I have a bullet object. It has a sprite, a body and a shape and it is dynamic. It moves using ep_body_apply_impulse_relative it receives when it is created, and it travels a straight line until he finds something. So far, everything works.
The problem is that I want the bullet to be destroyed once it collides either with enemies (dynamic bodies) and some environment objects (mostly static bodies) but I would like this event to be handled by EP and not by the Game Maker On Collision event for two reasons: first, the EP body and the bullet sprite do not coincide precisely so sometimes the body touches the other body before the sprite, resulting in a "bounce".
Second, for I want the bullet to knock enemies back according to the physics of the given world, so if I make the body smaller than the sprite and I use the On Collision event, the istance gets destroyed (setting an alarm up "desynchronizes" the physics) before the bounce(the sprite touches the other sprite before the body) and the result is no physics collision.
I think what I have not clear in my mind is how the contact and contact indexes work.
Is a contact created by two colliding bodies? From your tutorials it seems so (a contact is when the distance between two outer bodies < treshold), but then how do I store the bodies who made that contact? Does the contact index mean that index 0 = 1st contact, 1 = 2nd contact and so on?
What I have been trying so far is to use ep_world_collision_test_circle(global.world,8,x,y,0.1,1,2,3) to get the number of collisions the circle mask built on the body's shape does and then
if (coll_numb > 0) {
a= ep_world_get_collision_body(global.world,0);
other functions here
}
to get the id of the body the bullet collides with so to check if its an enemy or a tree and to destroy the istance according to the case.
This results in the bullet not appearing, probabily because the bullet's body touches the gun's body when it is created (although masks and groups are set properly - I think, since the bullet do not bounce or influences the body of the gun and viceversa-), while if I use 1 as the second argument in ep_World_get_collision I get an EP error saying that the body is not colliding while the bullet is traveling towards a body.
Also, I have not been able to find a way to relate the EP body id with the GM instance ID of the body. In other words, even if I get the ID of the body, how can I tell to EP that the body I got the ID from is the body (or a mask) of an instance of a GM "obj_block_static" object? Maybe this is more of an issue with my poor coding skills but understing how GM IDs and EP IDs relate between themselves would help a lot!
Sorry for the wall of text, and thanks in advance for your help!
And thanks again for creating EP!
Maarten Baert author · 29 May 2011, 18:20
I've added a new tutorial, this should help:
Collision detection
If two bodies overlap, EP creates a contact. But a contact can have either one contact point (a point-edge collision) or two contact points (an edge-edge collision). But you don't need the contact points if you're just trying to detect collisions.
Contacts have ids just like bodies and shapes, the world has a counter to keep track of the ids. The first contact will get id 1, the next contact id 2, et cetera. But if contact 1 is destroyed, the counter stays the same, so the next contact will get id 3 even though there are only 2 contacts.
The easiest way to do this is to store the id in a user variable. The tutorial shows how this works.
Tomcat2900 · 25 July 2011, 22:19
Hello !
I want to use the Extreme Physics for a ball game.
I tried 2 days to obtain what I want but I couldn't.
Please tell me how can I get the following result from the link below:
http://www.2shared.com/photo/X4QU8b3E/Balls.html
As you can see there the balls are aligned...
Please give me a sample.
Thank You!
Maarten Baert author · 2 August 2011, 02:48
That game is grid-based, ExtremePhysics isn't suitable for that kind of games. You should use a grid-based system. Did you read the official tutorial on maze games (link)?
Jomish · 28 August 2011, 02:13
I was wondering in your "platform example" how you could create a hinge at the point of collision with the player and another object.
Dll1024 · 9 September 2011, 03:07
Hi
im begginer to extremePhysics. i wrote this code in key press event(spacebar) of a dynamic object:
But after a few times pressing space button, game window fills with my object color!
Maarten Baert author · 11 September 2011, 01:27
That's because it's a local variable. You should really read a tutorial (or just the manual) about global vs. local vs. temporary variables in GM first, otherwise you will run into this kind of problems all the time :).
Read this if you're using GM8.1.
It's definitely possible. Read the tutorial on collision detection first:
http://www.maartenbaert.be/extremephysics/tutorials/collision-detection/
You can use the coordinate conversion functions to calculate the correct local coordinates. But it's not easy, and if you're new to GM you should really learn the basics first.
image_angle is in degrees, but ep_body_set_position expects radians (just like all other ExtremePhysics functions). You should use degtorad to convert it. Does this solve your problem?
Gregoryogan · 6 October 2011, 06:32
Hello!!
Hey i'm having some trubles here i'm trying to make a dynamic Body to move towards a point like
move towards a point mouse_x and Mouse_y, But that doesnt work, i tried to apply impulse its works but i cant reach the specific point like mouse_x and mouse_y.
Can you help please??
Greg
Maarten Baert author · 6 October 2011, 14:07
@Solarboy: You can get perfect 'elastic' collisions by setting 'restitution' to 1 for both shapes. So I don't think you will actually need the angle. Anyway, it doesn't work because in GM the Y axis points down, not up. So arctan2 returns incorrect results. This should work:
I don't know how you did the actual mirroring of the angle, but this is what I would do:
If you did something else, that might also be the cause :).
@Matt13: I created the functions ep_world_serialize and ep_world_unserialize exactly for situations like this. Basically you have to serialize the world right before you save the game, and destroy the world right before loading the game. When the game is loaded you should create the world again and unserialize it. I have never actually tried this with the built-in saving mechanism, though. Try this:
Does this work for you?
@Gregoryogan: Try this:
A_d_y · 13 October 2011, 12:01
i wanna rotate my boxchain :) how can i do that :) Actualy how can i update boxchain points.
Maarten Baert author · 13 October 2011, 12:20
Just rotate the body.
You can't, box chains are converted to normal box shapes when you call ep_body_boxchain_end. You have to write your own code if you want to change them afterwards.
Bavogames · 15 October 2011, 14:50
Is there a way to create a damage system?
ex. detect collisions and their force and use the force to change the heath of the object(more force = more damage)
Drivinucrazy Games · 22 October 2011, 02:27
Hey Maarten,
How do you get bodies to stop "squirming around" when piled up? I have a heap of boxes, and even with sleeping on, they don't want to stabilize.
These are my settings:
Maarten Baert author · 22 October 2011, 15:31
First read the tutorial about collision detection:
http://www.maartenbaert.be/extremephysics/tutorials/collision-detection/
When you've detected a collision, you can use ep_contact_get_point1_normalveldelta and ep_contact_get_point2_normalveldelta to get the impact velocity. You can also use the impact force, but I think it will look more realistic if you use the velocity.
Disable sleeping and solve the stability problem first, and when that works you can try to enable sleeping again. Your values for stable_maxvel and stable_maxrotvel are way too high, that might actually make it worse. Sleeping generally doesn't make the simulation more stable, it just hides the problem :).
Try setting baumgarte_factor to 0, and make sure the coefficient of restitution of the boxes isn't too high.
Erraticambassador · 23 May 2012, 22:55
Hello Maarten? I have gotten used to using your engine. But I have been getting stuck recently with adding textures to the polygons, which is the fastest way for me to add graphics to the game without using a ton of objects. I have a marker object to create the polygons at the point where I put them in the room (Like in your 'rolling_ball' example). I want to simply (If you can make it simple.) add a texture that doesn't just go on the polygons itself but loops endlessly until it reaches the bottom of the room. Similar to how you'd normally tile a room in GM. You got any ideas? Because this would really save me a lot of time and trouble.
Maarten Baert author · 3 June 2012, 21:05
If I understand your question correctly, you want to draw a polygon with a repeating texture. That's perfectly possible, just use
texture_set_repeat(true);right before drawing the polygon (with draw_primitive_begin_texture). The texture coordinates should be (x/texturewidth, y/textureheight).Erratic · 4 June 2012, 00:00
I forgot my old password so I created a new account, sorry. But anyways, that's exactly what I wanted but I don't know how you made the polygon and set it as a model, then added a texture to it, that confused me. I tried putting in the code you made but I got an error saying something about the vertices are greater than 3. I put 'vertices = 0' in the create and still no textures. Played around with it for a while but I still got errors. Could you explain how you made it?
Darkness50 · 6 June 2012, 22:48
hi maarteen
ı create just like a angry birds game with extreme physics but i didn't convert to html5 game
how can convert my game to html5 game help please
Maarten Baert author · 8 June 2012, 13:14
Take a look at the code I posted here, it's for multipolygons but that's almost the same.
HTML5 can't load DLLs because it runs as JavaScript. You could try to use the physics engine in GM:Studio though, but I can't help you with that (I don't have GM:Studio myself).
Solarboy · 14 June 2012, 05:18
Hey Maarten,
I've noticed that when you deactivate objects in game maker, they can get 'disconnected' from their physics bodies if the physics body is moved while the object is deactivated. I've been trying to optimize my game by deactivating objects that aren't on screen but this is proving to be a problem due to objects that are still activated pushing around the physics bodies of objects that are deactivated.
Do you have any thoughts on this or other methods to use when optimizing games that contain many physics bodies?
BTW, I am putting bodies that are off screen to sleep as well.
Maarten Baert author · 17 June 2012, 00:07
If possible, use the sleeping system in ExtremePhysics to make bodies that are out of view sleep (take a look at the big_world example, or the testbed test 'views'), that will save some CPU time. Then just reactivate all non-static objects every X steps (eg. 10), update all their locations (physics_object_get) and deactivate the ones that are still out of view again. It will take some processing time, but it should work (well, most of the time at least).
It would be even better if you could deactivate objects simply if the ExtremePhysics body is sleeping AND out of view, and activate them when the body stops sleeping, but I suspect you will waste more time checking the state of the bodies than you will gain.
Erratic · 21 June 2012, 22:30
What is the easiest way to implement wall gripping?
Maarten Baert author · 22 June 2012, 00:24
You could try to create a hinge joint when the body touches the wall. But it's probably a lot easier to apply a force to the body to push it against the wall.
Killpill · 21 July 2012, 01:49
The direction it is moving is a little more complex. I'm sure Maarten has a better way than my quick solution.
Maarten Baert author · 12 August 2012, 20:37
No, there is no easier way to do it. You're essentially converting a vector to an angle. ExtremePhysics uses vectors internally for almost anything, and I don't want to add unnecessary functions to the DLL.
Xsonicvision · 21 October 2012, 22:08
Hey Maarten, I have a couple questions. Okay, I'm trying to simulate a bullet breaking a box. When the box breaks, it seperates into 4 smaller boxes equal to the size of a big box. I'm giving all the boxes health points (hp), and the bullet gets attack points (ap) based on the bullets velocity. First, I would like to know how to make the negative values of the velocity into positives, because subtracting a negative value is adding to the hp. Also maybe you could give me a couple pointers on how you think I should approach this. I want the boxes to interact with physics and also break and destroy, like if i put 2 rows of 10 boxes, the bullet can go through and break 10 boxes - if i make the bullet faster and / or give it more mass it could break all 20? Thanks again Maarten, you're a genius.
Maarten Baert author · 26 October 2012, 00:50
This is a bit more complex than it sounds. ExtremePhysics has no concept of 'breaking' bodies, so if the bullet collides with the box, the bullet will simply lose all its velocity (unless it is heavy enough to move the box). That's not what you want in this case. Unfortunately there's no setting to change the maximum contact force. The closest thing I can come up with is to simply reset the velocity of the bullet to a fixed value each step. For example, the bullet starts with velocity 10 (the 'attack points'), and the velocity will be reset to 10 each step until the bullet collides with a box. At that point you can decrease the velocity to 8, for example. Each time the bullet collides with a box is slows down. If the velocity is too low, just destroy the bullet (slow bullets aren't realistic). This method is not exactly physically correct, but I expect it will look realistic enough.
PS: When you split a box into smaller boxes, don't forget to set the velocity of the new boxes to the velocity of the old box. The rotational velocity should be the same, and you can calculate the new x and y velocity with ep_body_get_xvel_local_point/ep_body_get_yvel_local_point (this will take the rotation into account). Without this, a flying box would just stop in mid-air when you shoot it.
Xsonicvision · 1 November 2012, 14:50
Maarten, can i show you a picture a gif of what is happening? or should i post up the codes?
Maarten Baert author · 1 November 2012, 15:20
Both would be best :). Is it working correctly now?
By the way, I've set up an Atom feed that shows all new comments here, so now I should be able to reply a lot faster.
Ruby · 13 December 2012, 00:17
Hey Maarten I saw your game "The Machine" and it gave me an idea for a game sort of similar. I have a question though, how did you do the drag and drop system? Thanks and great work on the Physics engine!
Maarten Baert author · 13 December 2012, 00:44
Take a look at the testbed (mainly the step event of obj_controller), I used the same method there. I just added a motor to stop the rotations (same as here). Good luck :).
Justinweq · 31 January 2013, 02:43
Hi i need some help i am trying to make a hinge joint but i can not figure out how to locate the next closest body please help!
ep_hingejoint_create(global.world,body,?,4,-8,4,8,0);
The question mark is the body_id that i want(i obviously got the first body_id).
Maarten Baert author · 31 January 2013, 14:26
Okay, what are you trying to do? Do you want something like the testbed, where you can click and drag things with the mouse? If you want to know what bodies are at a specific position, you can use ep_world_collision_test_circle (set the radius to zero to get a point) followed by ep_world_get_collision_body.
Solarboy · 9 February 2013, 00:44
Hi again Maarten,
I've been using ExtremePhysics as a big part of my game for a while now and I was thinking of moving over to GameMaker Studio for development reasons. Now, I understand you don't have Studio, and asking you not only to get it but also to figure out how to get ExtremePhysics running on there seems like a pretty ridiculous request. So I've decided to try to figure it out myself, if there is a way, although I'm not incredibly versatile with thinking about code on a scale as large as this. So I guess what I'm saying is I have some theoretical questions involving this endeavor and I was hoping you'd indulge me.
First off, the biggest hurtle. If there is no way to do this then I'll have to quite here and now. As far as I can tell, ExtremePhysics pretty thoroughly uses the function execute_string, which GMS doesn't support. Could you see any alternative methods then the use of execute_string in the cases it's used? I partially ask because I'm not quite sure why you chose to use this method in the first place. I don't mean that as some sort of passive aggressive statement by the way, I literally mean I don't understand for what reasons it would have been better to use execute_string over another method, if one existed that is.
Additionally, I've seen mentions that if it could work, the overlay would no longer be functional. Could you imagine any truth to this? Any methods the the overlay function uses that may no longer be supported?
The project I'm working on is big and I'm passionate about it. If you don't think ExtremePhysics could be modified then I'll just have to live with it. I really appreciate your time and thank you again for making ExtremePhysics in itself. I've learned almost all I know about GML while fooling around with it, so I suppose I owe you a lot.
Cheers!
Maarten Baert author · 14 February 2013, 02:58
I don't know where you got that, I never use execute_string at all! The only part of ExtremePhysics that depends on GM itself is debug drawing (using get_function_address), and that part is completely optional.
If you are wondering why the extension doesn't work in Studio, it's because of a known bug in Studio:
http://gmc.yoyogames.com/index.php?showtopic=546548
You would have to fill in the 'external name' field for each function manually in the extension editor, which takes quite some time because it can't be automated, so haven't done this. Someone else did though, you can download it here:
http://g2f.nl/0ic39bd
I haven't tested it but this one is supposed to work - on Windows, that is.
If you mean debug drawing, then yes, you are right. Fixing it is possible (assuming get_function_address still exists) but requires some changes to the 'GMaker' code (Delphi and C++ are quite different). It's probably not easy to do because it involves disassembling parts of the GM runner, and it's completely impossible for me since I don't have Studio. And I really don't feel like buying it since (1) I use linux almost exclusively these days, (2) I prefer C++, and (3) I don't really like some of the design decisions YYG made with Studio, especially the lack of extension support on all platforms (there's no technical reason why ExtremePhysics wouldn't run on Android and iOS except support from YYG - I've actually used ExtremePhysics on a Raspberry Pi and it worked just fine, no issues whatsoever).
If you can live without debug drawing and you only want to support Windows (and maybe Mac), you're fine. Otherwise you could try the built-in physics engine (I have no idea whether that one has debug drawing though, and there were some resource leak issues I've heard).
Glad to hear that :).
Hilmy Irung Separo · 28 April 2013, 03:13
hi,
one of your example requiring an older extreme physic extension.can you upgrade the example to use extrem physic 2.2 or i must use the both of extreme physic?
thanks for your answer
PS.:sorry for my bad english.im from indonesian
btw.what is your facebook account? add me:https://www.facebook.com/hilmyfarhannn?ref=tn_tnmn
my email:*****
Maarten Baert author · 28 April 2013, 05:20
Which example? I recently added a few examples that weren't included by default, and I forgot to update them, but now I'm not even sure which ones they were. These ones are probably outdated:
- collision_sounds
- collision_sparks
- orientation_follows_direction
Was it one of those?
PS: I don't use facebook, but you can mail me if you want :). My address is in LICENSE.txt (you shouldn't post email addresses in plain text, spam bots will find them).
Grekepten · 12 February 2014, 22:43
I'm not sure where to post this, so sorry if this is the wrong section.
I just installed EP and now I'm starting to check the examples.
I know this is a noob question, but, what's the purpose of draw_sprite_corrected()? I mean, why do you have to make a correction to x and y?
Sorry for my english, and Thank you very much for EP.
Maarten Baert author · 14 February 2014, 12:26
That's because the function draw_sprite_ext is buggy. If you rotate a sprite 180 degrees, you will see that it is drawn in the wrong location (shifted by one pixel). draw_sprite_corrected moves the sprite back in the opposite direction to fix this bug.
Contramuffin · 16 December 2015, 06:09
Hi, I'm a bit curious when I saw that you created a physics engine in C++ for GameMaker when I was searching up physics engines. I'm trying to create a game on GameMaker, and I want to build a custom engine. How would you use another programming language on GameMaker? And would it be worth it to do that instead of just making one in GML?
Maarten Baert author · 18 December 2015, 00:58
A long time ago I wrote a tutorial about creating your own (simple) physics engine in GM. It uses GML but the theory applies to any programming language. You can read it here:
http://www.game-maker.nl/forums/topic,53515
The text is in Dutch, but you can still use the examples. They should be pretty easy to understand, because they gradually become more complex, with each example adding one more feature to the previous one.
Krishiv768 · 1 June 2017, 13:42
How do I make the ball bounce higher than what it is.(using the rolling ball example)
I do not want to change the gravity.Also how do I make the ball jump in the direction of normal of the contact body?
Im currently changing the normalvelocity to something else and quickly changing it back to 0 to jump. Is there any better way to do this?
Maarten Baert author · 1 June 2017, 23:25
If you want the ball to jump away from whatever it is touching, you can use ep_shape_set_material to temporarily change the normal velocity of the ball to a positive value. This should produce the effect you want.
Krishiv768 · 2 June 2017, 09:19
Thanks. But now im facing another problem.
How do I make the ball roll up surfaces without having to run-back-then-run-forward-with-enough-speed roll up. The ball gets stuck spinning between the floor and the ramp.
The ball gets stuck in this position.
O
/ / O/ /-------
____O/. The ball should roll up like this ____O/. ____/. ____/.
Maarten Baert author · 4 June 2017, 02:23
You can avoid this by reducing the coefficient of friction of the ball. If that doesn't work, please show me a screenshot or video, I'm not sure whether I understand your problem correctly.
Krishiv768 · 5 June 2017, 07:28
This happens http://imgur.com/1kHRihI
Also the bouncy effect thingy is intentional
Maarten Baert author · 5 June 2017, 21:14
The ball isn't stuck, it just doesn't have enough traction to roll up a 45 degree slope. In that case the coefficient of friction is too low. If you want to maintain traction on steep slopes like that, you need a coefficient of friction higher than 1, but that will get you stuck in 90 degree corners.
The easiest option is to just redesign your levels so they don't use 45 degree slopes in places where the player can't get enough speed to roll or jump up.
Krishiv768 · 28 June 2017, 12:15
So I need to make a tornado like obstacle with a conical "force" field like a magnet but in all directions.
Maarten Baert author · 29 June 2017, 00:00
Is that a question? I don't understand what you mean.
Karst · 22 June 2021, 23:25
Hello there Maarten. Maybe you don't even check this page anymore and surely you don't got time to answer questions about this extension anymore.
Thing is i'm running through a lot of old (2011 Era) Game Maker 8-8.1 Projects and most of them did use the ExtremePhysics 2.1. But thing is all of them suddenly have kinda "transparent" collisions. I mean things don't even collide anymore. But the extension is properly installed since things like apply forces and gravity still working. I did check the code line by line and compared it to the examples include in that version.
Surprisingly the examples work properly but all the different versions which they were working have this absence of collisions.
Can be caused by the difference in the OS Since now its executing in a Windows 10 Pro?. If its possible I would try to play/edit/compile them in a Win7 Virtualization.
Anyways thanks for your time. Your extension gave me a lot of funny hours a long time ago!.
Maarten Baert author · 8 July 2021, 00:21
Missing collisions specifically can be caused by failing to call ep_world_update_contacts before ep_world_simulate_step. IIRC in some older versions of ExtremePhysics there was no ep_world_update_contacts and the collision processing was done in ep_world_simulate_step.
If that doesn't help: Are you using the DLL+scripts, or the GEX extension? Normally I would recommend the GEX for performance reasons, however I think some examples use the DLL+scripts because that made development easier for me (no need to create a new extension every time I made a change to the code). So that might explain why the examples work while your own projects don't.
Windows has some options for running software in Windows 7 compatibility mode, this might help.