Tutorials
Comments
Tenkeral |
Comment #1: Wed, 23 Jun 2010, 10:53 (GMT+1, DST) he program asks me the file "Extreme Physics 2.1.dat" and the download does not contain this. Is there any solution? |
Maarten BaertAdministrator |
Comment #2: Wed, 23 Jun 2010, 16:23 (GMT+1, DST) Quote: Tenkeral
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). Last modified: Wed, 23 Jun 2010, 16:25 (GMT+1, DST) |
Retarded_lemon |
Comment #3: Fri, 6 Aug 2010, 4:00 (GMT+1, DST) 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 |
Omaga |
Comment #4: Sat, 7 Aug 2010, 21:28 (GMT+1, DST) Is there a sample .gmk file that uses this? I would like to use the dll but I cant seem to put it to use in my game. A great example would be where a few objects in a topdown can be moved, and do there physics stuff like collisions. And would it be possible to include this in a game that allready has controld movement with the v&hspeed that is allready part of GM? (I have a feeling I may have compatibility problems beacuse of this) Last modified: Sat, 7 Aug 2010, 21:41 (GMT+1, DST) |
Retarded_lemon |
Comment #5: Mon, 9 Aug 2010, 1:35 (GMT+1, DST) @ 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: @ 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 BaertAdministrator |
Comment #6: Tue, 10 Aug 2010, 20:26 (GMT+1, DST) Quote: Retarded_lemon
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. |
Ccj |
Comment #7: Tue, 17 Aug 2010, 17:18 (GMT+1, DST) 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 BaertAdministrator |
Comment #8: Thu, 19 Aug 2010, 14:28 (GMT+1, DST) Quote: Ccj
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? Sure, you can use polygons to do that. GamerXP has made a program that generates code for polygons. You can download it here: |
Ccj |
Comment #9: Thu, 26 Aug 2010, 8:26 (GMT+1, DST) 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 |
Comment #10: Fri, 27 Aug 2010, 15:12 (GMT+1, DST) 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 |
Comment #11: Mon, 30 Aug 2010, 21:19 (GMT+1, DST) 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 BaertAdministrator |
Comment #12: Wed, 1 Sep 2010, 18:11 (GMT+1, DST) Quote: Ccj
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. Last modified: Wed, 1 Sep 2010, 18:18 (GMT+1, DST) |
Ccj |
Comment #13: Thu, 9 Sep 2010, 16:21 (GMT+1, DST) Hmm, OK I'll check out the example you mentioned and give the spheres on springs technique a try. Would the latter actually be able to deform the sprite it was bound to though? 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! Thanks, CCJ |
Ccj |
Comment #14: Fri, 10 Sep 2010, 23:23 (GMT+1, DST) 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 BaertAdministrator |
Comment #15: Sun, 12 Sep 2010, 18:09 (GMT+1, DST) Quote: Ccj
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. Last modified: Sun, 12 Sep 2010, 18:09 (GMT+1, DST) |
Ccj |
Comment #16: Thu, 16 Sep 2010, 21:21 (GMT+1, DST) 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 BaertAdministrator |
Comment #17: Fri, 17 Sep 2010, 21:45 (GMT+1, DST) Quote: Ccj
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. EDIT 2: Fixed. Last modified: Fri, 17 Sep 2010, 21:54 (GMT+1, DST) |
Chance |
Comment #18: Mon, 4 Oct 2010, 4:39 (GMT+1, DST) Hope this comment is in the right place... Maarten, your engine is fantastic. I've only just started to use it, but I can see the potential. The functions are easy to understand and VERY powerful! What an incredible contribution to the GM community you've made here. Thank you so much. |
Retarded_lemon |
Comment #19: Tue, 30 Nov 2010, 21:35 (GMT+1, DST) 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 BaertAdministrator |
Comment #20: Fri, 10 Dec 2010, 20:30 (GMT+1, DST) Quote: Retarded_lemon
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. |
Retarded_lemon |
Comment #21: Sat, 11 Dec 2010, 1:38 (GMT+1, DST) Quote: Maarten Baert
Quote: Retarded_lemon
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. Look forward to your response Retarded Lemon |
Maarten BaertAdministrator |
Comment #22: Tue, 14 Dec 2010, 18:49 (GMT+1, DST) Quote: Retarded_lemon
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 ... |
Johnmenez |
Comment #23: Fri, 21 Jan 2011, 0:37 (GMT+1, DST) This is what i'm looking for. Nice work. However, I have a question, how do I detect collision in ray casting? |
Maarten BaertAdministrator |
Comment #24: Tue, 25 Jan 2011, 18:11 (GMT+1, DST) Quote: Johnmenez
This is what i'm looking for. Nice work. However, I have a question, how do I detect collision in ray casting? ep_world_ray_cast returns -1 if there is no collision. If the return value is any other number, there is a collision. |
Ross93 |
Comment #25: Wed, 2 Mar 2011, 3:05 (GMT+1, DST) 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: xx=ep_body_get_xvel_center(global.world, body) yy=ep_body_get_yvel_center(global.world, body) if keyboard_check(vk_up) then yy=-1 *movement_speed else if keyboard_check(vk_down) then yy=1 *movement_speed if keyboard_check(vk_left) then { xx=-1 *movement_speed if keyboard_check(vk_up) then { xx=1 / sqrt(2) *-1 *movement_speed yy=1 / sqrt(2) *-1 *movement_speed } if keyboard_check(vk_down) then { xx= 1 /sqrt(2) *-1 *movement_speed yy= 1 /sqrt(2) *movement_speed } } else if keyboard_check(vk_right) then { xx=1 *movement_speed if keyboard_check(vk_up) then { xx= 1/sqrt(2) *movement_speed yy= 1/ sqrt(2) *-1 *movement_speed } if keyboard_check(vk_down) then { xx= 1/ sqrt(2) *movement_speed yy= 1/sqrt(2) *movement_speed } } ep_body_set_velocity_center(global.world, body, xx,yy,0) where movement_speed is a constant defining how fast I want the character to move in the game Cheers Ross |
Maarten BaertAdministrator |
Comment #26: Sat, 5 Mar 2011, 19:08 (GMT+1, DST) Quote: Ross93
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 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. Last modified: Sat, 5 Mar 2011, 19:09 (GMT+1, DST) |
Dillerkind |
Comment #27: Thu, 10 Mar 2011, 13:30 (GMT+1, DST) 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 BaertAdministrator |
Comment #28: Tue, 15 Mar 2011, 20:35 (GMT+1, DST) Quote: Dillerkind
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. 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. |
Johnmenez |
Comment #29: Mon, 28 Mar 2011, 10:12 (GMT+1, DST) 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 BaertAdministrator |
Comment #30: Wed, 30 Mar 2011, 14:41 (GMT+1, DST) Quote: Johnmenez
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? 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). |
Vortex |
Comment #31: Wed, 11 May 2011, 16:06 (GMT+1, DST) I officially love you... |
Gboy |
Comment #32: Tue, 24 May 2011, 15:38 (GMT+1, DST) Hi Maarten! 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. 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 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! |
Thootje |
Comment #33: Sat, 28 May 2011, 14:32 (GMT+1, DST) wow! thootje |
Maarten BaertAdministrator |
Comment #34: Sun, 29 May 2011, 18:20 (GMT+1, DST) Quote: Gboy
Hi Maarten! I seem however not able to handle collisions properly when it comes to integrating your functions with GM's ones. I've added a new tutorial, this should help: Quote: Gboy
I think what I have not clear in my mind is how the contact and contact indexes work. 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. Last modified: Sun, 29 May 2011, 18:20 (GMT+1, DST) |
Gboy |
Comment #35: Mon, 30 May 2011, 11:57 (GMT+1, DST) Quote: Maarten Baert
The easiest way to do this is to store the id in a user variable. The tutorial shows how this works. Your new tutorial is God sent! Exactly what I needed to optimize my code!Many many thanks! Beforehand I solved my collision problem with two workarounds in the bullet's step event. This one was telling the bullet to destroy itself when a "virtual" collision with any kind of object (enemies and environment blocks) happens (the instance_destroy function was handled by the EP body updating script): coll_numb = ep_world_collision_test_circle(global.world,8,x,y,0.1,2,1,1); if (coll_numb = 1) { a= ep_world_get_collision_body(global.world,0); if (ep_body_exists(global.world, a)) { xcoll = ep_body_get_x_center(global.world, a); ycoll = ep_body_get_y_center(global.world, a); ep_body_apply_impulse_relative(global.world,a,xcoll,ycoll,xvel,yvel,0,1,1); } ep_body_destroy(global.world,bullet); coll_numb = 0; } while the following was controlling the damage done by the bullet (still in the stp event) in case it would have hit an object_enemy (the two virtual shapes in the two codes have different collision masks): //Damages enemies en_hit = ep_world_collision_test_circle(global.world,8,x,y,0.1,4,4,1); if (en_hit = 1) { b = ep_world_get_collision_body(global.world,0); x_body = ep_body_get_x_center(global.world, b); y_body = ep_body_get_y_center(global.world, b); with(obj_enemy) { if point_distance(x,y,other.x_body,other.y_body) <= 1 { en_health -= obj_damage_controller.shot_damage; } } } The system worked but it forced me to mess around too much with zillion of collision masks and it creates too many virtual shapes per object, messing up also the natural EP collisions handling. Not to mention the nested "if" statements and the distance checks between the body and the object - the "body update" script is made in such a way that the object's (x,y) follow the body's coordinates -. Your code avoids all the extra work both for me and for my poor processor and that's just great :D Not only that, but I guess my poor code, by acting on virtual shapes, was somehow imparing EP native collision handling since bounces and impulses were "artificial". With your new tutorial all this is avoided, and that's just great! Thanks again for the amazing work and for your kindness and availability! Best wishes! |
Tomcat2900 |
Comment #36: Mon, 25 Jul 2011, 22:19 (GMT+1, DST) Hello ! 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 BaertAdministrator |
Comment #37: Tue, 2 Aug 2011, 2:48 (GMT+1, DST) Quote: Tomcat2900
Hello ! 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)? |
Jomish |
Comment #38: Fri, 26 Aug 2011, 18:49 (GMT+1, DST) Maarten-I've been learning to work with your engine...By the way, thank you very much and very great job! Problem: Details: I place an object on a map where-in the create event executes code to create an obj_1 and I load a sprite to the obj_1 and it works fine (like in platform example).... but when I try to join it with any joints I have to declare a second body, so I try to ep_hingejoint_create(global.world,body1,body2,0,-20,0,0); 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. So now I made two bodies in the create event of obj_1 but the draw_sprite_corrected isn't showing up. My question is how do I join to two different objects, obj_1 and obj_2? p.s. (i hope i'm not too confusing...) |
Jomish |
Comment #39: Fri, 26 Aug 2011, 19:30 (GMT+1, DST) Maarten, here is my create object event code, but only one sprite (body) is draw and it flops off the screen body = ep_body_create_dynamic(global.world,false); global.multi_poly_arrow1 = ep_world_multipoly_begin(global.world,9); ep_world_multipoly_set_vertex(global.world,0,-39,-9); poly_first_0 = ep_world_multipoly_get_first(global.world); //ep_polygon_initialize(global.world,global.multi_poly_arrow1); shape1 = ep_shape_create_polygon(global.world,body,global.multi_poly_arrow1,0,0,0,1); for(i=poly_first_0;i<=poly_last_0;i+=1) { ep_body_calculate_mass(global.world,body); ////////////// body2 = ep_body_create_dynamic(global.world, false); global.multi_poly_arrow2 = ep_world_multipoly_begin(global.world,9); ep_world_multipoly_set_vertex(global.world,0,-39,-9); poly_first_0 = ep_world_multipoly_get_first(global.world); //ep_polygon_initialize(global.world,global.multi_poly_arrow2); shape1 = ep_shape_create_polygon(global.world,body2,global.multi_poly_arrow2,0,0,0,1); for(i=poly_first_0;i<=poly_last_0;i+=1) { ep_body_calculate_mass(global.world,body2); ep_hingejoint_create(global.world,body,body2,39,16,39,16,0); physics_object_set(body); |
Jomish |
Comment #40: Sun, 28 Aug 2011, 2:13 (GMT+1, DST) 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 |
Comment #41: Fri, 9 Sep 2011, 3:07 (GMT+1, DST) Hi ep_body_set_position(global.world, body, x, y-25, image_angle); But after a few times pressing space button, game window fills with my object color! |
Maarten BaertAdministrator |
Comment #42: Sun, 11 Sep 2011, 1:27 (GMT+1, DST) Quote: Jomish
but when I try to join it with any joints I have to declare a second body, so I try to ep_hingejoint_create(global.world,body1,body2,0,-20,0,0); 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! Read this if you're using GM8.1. Quote: Jomish
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: Quote: Dll1024
Hi ep_body_set_position(global.world, body, x, y-25, image_angle); 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? Last modified: Sun, 11 Sep 2011, 1:36 (GMT+1, DST) |
Solarboy |
Comment #43: Thu, 29 Sep 2011, 6:57 (GMT+1, DST) Hey Maarten, your physics engine rocks! Thank you so much for making it! I've made more progress in the months that I've been using it then the whole four years I've been working on my game. Now for a question... I'm trying to make an object, (A), bounce off another, (B), similarly to how light reflects off a mirror. So I need to calculate the normal of object (B) when (A) collides with it, thankfully you've got that covered with 'ep_contact_get_normal_x' and 'ep_contact_get_normal_y'. So I made this code to return the normal in degrees: contact=ep_shape_get_first_contact(global.world,body,shape) normal_x=ep_contact_get_normal_x(global.world, contact) normal_y=ep_contact_get_normal_y(global.world, contact) normal=radtodeg(arctan2(normal_y,normal_x)) At first I thought it worked but that was far from the truth -_- Essentially, horizontal collisions are backwards, so for instance, if (A) collides with the left of (B) it returns 0 when really it should return 180. Although diagonals and everything in between doesn't work, vertical collisions appear to work for some reason. So..um..do you have any idea what the problem is? My friends and I have been wracking our brains for days and can't seem to figure out whats going on. I personally think my math is just wrong :I I also have a question about collision filtering, I thought I understood it at first but apparently I don't :P Thanks. |
Matt13 |
Comment #44: Sun, 2 Oct 2011, 1:43 (GMT+1, DST) Hello. I am having a problem with my current game. I am using ExtremePhysics 2.2 to simulate dead bodies. Every so often, the player activates a save station and it saves the game using the gamemaker function. When the player dies it loads the game. When i load the game, i get a Extremephysics error everytime. Somthing about an object not being found. To try to solve this problem, i tried destroying the world befor loading, then after the loading block put create world. (something like this) (if player is dead) I got an error that the world was never created. How do i automatically create another world when the game is loaded???? Please help Matt |
Gregoryogan |
Comment #45: Thu, 6 Oct 2011, 6:32 (GMT+1, DST) 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 BaertAdministrator |
Comment #46: Thu, 6 Oct 2011, 14:07 (GMT+1, DST) @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); Last modified: Thu, 6 Oct 2011, 14:17 (GMT+1, DST) |
Gregoryogan |
Comment #47: Thu, 6 Oct 2011, 15:49 (GMT+1, DST) Hey Maarten! Hey that worked Thank you!! Hey i think a lot of GM user uses this function to move objects around and even to follow another object when placed in the Step events so thanks to you i could make a function, if you are going to release a new version of the amazing engine you could add this with the update it would be a great help for the other users, what you think? Thanks again! Function ep_body_move_towards_point(x,y,velocity) var v, vx, vy, d; |
Solarboy |
Comment #48: Sun, 9 Oct 2011, 9:12 (GMT+1, DST) Oh man that works great, thanks! The reversed Y was what messed us up, otherwise we were much closer then I thought, literally the code was identical other then the negative sign :P Again, thank you! Your the best! |
A_d_y |
Comment #49: Thu, 13 Oct 2011, 12:01 (GMT+1, DST) i wanna rotate my boxchain :) how can i do that :) Actualy how can i update boxchain points. |
Maarten BaertAdministrator |
Comment #50: Thu, 13 Oct 2011, 12:20 (GMT+1, DST) Quote: A_d_y
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. |
Bavogames |
Comment #51: Sat, 15 Oct 2011, 14:50 (GMT+1, DST) Is there a way to create a damage system? |
Drivinucrazy Games |
Comment #52: Sat, 22 Oct 2011, 2:27 (GMT+1, DST) 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. ep_world_set_settings(world,1/room_speed,20,10,0.5,0.5,0.1,0.5,1); ep_world_set_sleeping(world,1,0.1,0,200,3); Last modified: Sat, 22 Oct 2011, 2:31 (GMT+1, DST) |
Maarten BaertAdministrator |
Comment #53: Sat, 22 Oct 2011, 15:31 (GMT+1, DST) Quote: Bavogames
Is there a way to create a damage system? First read the tutorial about collision detection: 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. ep_world_set_settings(world,1/room_speed,20,10,0.5,0.5,0.1,0.5,1); ep_world_set_sleeping(world,1,0.1,0,200,3); 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. |
Drivinucrazy Games |
Comment #54: Sun, 23 Oct 2011, 1:01 (GMT+1, DST) Quote
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. Oh man, thanks. I set the sleeping values way down (10 and 1) and set baumgarte_factor to 0 and it's looking a lot more stable :D |
Ninajejoe5 |
Comment #55: Wed, 16 Nov 2011, 17:15 (GMT+1, DST) I just wanted to say i have had this dll for a while now, and i have always wanted to use it but could never get a grasp on it, i could understand it but i was like whoa complicated, i i finnaly said f it might as well just put the variables together like you said, and you know it's really not all that comlicated its acctualy pretty staight forward, so thanks man keep it up, this is really gonna help me make the kinda games i want to. |
Erraticambassador |
Comment #56: Wed, 23 May 2012, 22:55 (GMT+1, DST) 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. Last modified: Wed, 23 May 2012, 22:56 (GMT+1, DST) |
Maarten BaertAdministrator |
Comment #57: Sun, 3 Jun 2012, 21:05 (GMT+1, DST) Quote: Erraticambassador
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). |
Erratic |
Comment #58: Mon, 4 Jun 2012, 0:00 (GMT+1, DST) 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? Last modified: Mon, 4 Jun 2012, 0:04 (GMT+1, DST) |
Darkness50 |
Comment #59: Wed, 6 Jun 2012, 22:48 (GMT+1, DST) hi maarteen Last modified: Thu, 7 Jun 2012, 9:54 (GMT+1, DST) |
Maarten BaertAdministrator |
Comment #60: Fri, 8 Jun 2012, 13:14 (GMT+1, DST) Quote: Erratic
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 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). Last modified: Fri, 8 Jun 2012, 13:16 (GMT+1, DST) |
Erratic |
Comment #61: Sat, 9 Jun 2012, 20:44 (GMT+1, DST) Thanks Maarten, I'll use that. |
Solarboy |
Comment #62: Thu, 14 Jun 2012, 5:18 (GMT+1, DST) 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 BaertAdministrator |
Comment #63: Sun, 17 Jun 2012, 0:07 (GMT+1, DST) Quote: Solarboy
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. 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. |
Solarboy |
Comment #64: Mon, 18 Jun 2012, 11:16 (GMT+1, DST) Quote: Maarten Baert
Quote: Solarboy
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. 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. Oh, ok! Man, what would I do without you. Your engine and advise has really...well, changed my life to be honest. I've learned so much using this and my game runs like a dream now. Large room sizes and many physics bodies don't seem to be that much of a problem anymore. Anyway, for anybody curious about exactly how to do this: what I ended up doing was having the main controller object execute this in alarm[0]: global.beacon=true; instance_activate_object(obj_dynamic_parent); global.beacon=false; alarm[0]=10 Which then makes every child of 'obj_dynamic_parent' execute: switch global.beacon = true{ case x > view_xview-100 && x < view_xview+view_wview[0]+100 && y > view_yview-100 && y < view_yview+view_hview[0]+100 : physics_object_set(body); break; } Which makes sure the object stays with it's physics body. To make sure no hiccups occur, the world's sleep settings are as follows: ep_world_set_sleeping(global.world,true,60,1,0.01,0.001); Finally, I set the view rectangle that makes objects sleep to be larger then that of the game's view port so that objects that are frozen in place have time to react while off screen, so thing's like projectiles don't wait for you to catch up to them. Teamed up with this and the use of a lot of different parent child relationships for objects that need to remain permanently active, everything seems to work pretty well for me at least. |
Erratic |
Comment #65: Thu, 21 Jun 2012, 22:30 (GMT+1, DST) What is the easiest way to implement wall gripping? |
Maarten BaertAdministrator |
Comment #66: Fri, 22 Jun 2012, 0:24 (GMT+1, DST) Quote: Erratic
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. |
Erratic |
Comment #67: Fri, 22 Jun 2012, 15:25 (GMT+1, DST) I was thinking about doing something like that. Create an invisible hinge joint that follows and connects to the top of the player. But one that doesn't collide with any walls. I saw some of your examples of slider joints that did something like that. |
Darkness50 |
Comment #68: Fri, 22 Jun 2012, 15:49 (GMT+1, DST) hi maarten how can ı draw this polygon help me |
Erratic |
Comment #69: Fri, 22 Jun 2012, 16:00 (GMT+1, DST) Quote
hi maarten how can ı draw this polygon help me You could use Polygon Creator. It's right here on the site. It should do exactly what you want. Last modified: Fri, 22 Jun 2012, 16:13 (GMT+1, DST) |
Darkness50 |
Comment #70: Sat, 23 Jun 2012, 17:40 (GMT+1, DST) Quote: Erratic
Quote
hi maarten how can ı draw this polygon help me You could use Polygon Creator. It's right here on the site. It should do exactly what you want. thanks body ıt very nice |
Killpill |
Comment #71: Tue, 17 Jul 2012, 4:09 (GMT+1, DST) I ran into a bit of a problem with this system. I am using sprites sized in powers of two with shapes that are the same width/height as them. With boxes this creates an issue with the left and top having the border on the edge of the sprite but the right and bottom are one pixel too large. This causes a very ugly effect when an object is rotated: My game has a map editor where you can rotate objects and this is a huge problem. Is there any way to fix this without adjusting all the sprites to be odd when divided by two (I'm guessing this is the issue)? I tried setting the width and height one pixel smaller but that doesn't fix the issue. EDIT: Nevermind. This problem was addressed in a tutorial. Quote
// draw_sprite_corrected(sprite, subimage, x, y, xscale, yscale, rot, color, alpha) Drawing the sprite with this function does fix my issue. Last modified: Sun, 22 Jul 2012, 18:27 (GMT+1, DST) |
Xsonicvision |
Comment #72: Wed, 18 Jul 2012, 12:47 (GMT+1, DST) Hi there, I have a question, and i need a little help. I've just started using extremephysics, I think its amazing, I'm just not very familiar with the language. For the rolling ball example, i would like to set the angle of the sprite to the angle of the floor, or to the angle at which the ball is moving. I've also noticed on the testbed example in test number two (and all other tests i believe) when i activate the drawing debug for velocity, in pink it shows me the angle that im looking for, but i can't seem to figure out which variable it is?? Can some one help me please? |
Killpill |
Comment #73: Wed, 18 Jul 2012, 22:04 (GMT+1, DST) Use ep_body_get_rot(). The value will be in radians so use radtodeg() to convert. It should end up looking something like this: image_angle = radtodeg(ep_body_get_rot(global.world,body)); |
Xsonicvision |
Comment #74: Thu, 19 Jul 2012, 6:59 (GMT+1, DST) im not too sure what im doing wrong, i want to find the direction that the ball is moving in, such as the game maker version of direction 0 - 360 here is the code im using var dir; Last modified: Thu, 19 Jul 2012, 7:01 (GMT+1, DST) |
Killpill |
Comment #75: Sat, 21 Jul 2012, 1:49 (GMT+1, DST) 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_); Last modified: Sat, 21 Jul 2012, 1:50 (GMT+1, DST) |
Xsonicvision |
Comment #76: Sat, 21 Jul 2012, 6:28 (GMT+1, DST) Oh yeah killpill, you're a genius. Check me out on sonic-online.com. Thanks for the help you guys are awesome.. |
Maarten BaertAdministrator |
Comment #77: Sun, 12 Aug 2012, 20:37 (GMT+1, DST) Quote: Killpill
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. |
Xsonicvision |
Comment #78: Thu, 23 Aug 2012, 5:15 (GMT+1, DST) [/quote] Thanks Maarten, I haven't run into any other problems using your program, i appreciate all of the help and I am sure I will be returning soon for more of it. im working on a sonic game and your engine is AMAZING!!! Thanks a bunch. |
Xsonicvision |
Comment #79: Sun, 21 Oct 2012, 22:08 (GMT+1, DST) 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 BaertAdministrator |
Comment #80: Fri, 26 Oct 2012, 0:50 (GMT+1, DST) Quote: Xsonicvision
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. |
Slon |
Comment #81: Fri, 26 Oct 2012, 1:16 (GMT+1, DST) Hi Maarten! Thank you for your EP, i like it more than Box2D that GM Studio provide now. I have 1 question. |
Xsonicvision |
Comment #82: Fri, 26 Oct 2012, 15:42 (GMT+1, DST) Quote: Slon
I cannot measure the speed of my objects. For example, the main character must die when his x_speed is more than 10 m/s. But how i can get that variable? What operator/command i should use? I believe it would look something like - if (ep_body_xvel_center(global.world, body) > 10) {instance_destroy()} Also you can refer to a variable that is set to the x velocity var xspeed; xspeed = ep_body_xvel_center(global.world,body) if (xspeed > 10) {instance_destroy()} I use Maarten's reference page alot and read through the forum as well before I ask alot of questions, because alot of the questions I've had were already discussed. It was very helpful to read through other peoples questions and Maarten's advice. If you would like to see or read the value, use the drop and drag 'set variable' Last modified: Fri, 26 Oct 2012, 15:45 (GMT+1, DST) |
Slon |
Comment #83: Mon, 29 Oct 2012, 8:09 (GMT+1, DST) Quote: Xsonicvision
Quote: Slon
I cannot measure the speed of my objects. For example, the main character must die when his x_speed is more than 10 m/s. But how i can get that variable? What operator/command i should use? I believe it would look something like - if (ep_body_xvel_center(global.world, body) > 10) {instance_destroy()} Also you can refer to a variable that is set to the x velocity var xspeed; xspeed = ep_body_xvel_center(global.world,body) if (xspeed > 10) {instance_destroy()} I use Maarten's reference page alot and read through the forum as well before I ask alot of questions, because alot of the questions I've had were already discussed. It was very helpful to read through other peoples questions and Maarten's advice. If you would like to see or read the value, use the drop and drag 'set variable' Thanx a lot, man! This answer is really helpful for me! |
Xsonicvision |
Comment #84: Mon, 29 Oct 2012, 16:06 (GMT+1, DST) Quote: Slon
Thanx a lot, man! This answer is really helpful for me! No problem, If you need more help don't be afraid to ask. I know Maarten is busy sometimes. So did it work out? |
Slon |
Comment #85: Wed, 31 Oct 2012, 0:50 (GMT+1, DST) Yeah, here is the final code if ep_body_get_xvel_center(global.world,body) >= 1 {special action} if ep_body_get_yvel_center(global.world,body) >= 1 {special action} |
Xsonicvision |
Comment #86: Thu, 1 Nov 2012, 14:50 (GMT+1, DST) Maarten, can i show you a picture a gif of what is happening? or should i post up the codes? |
Maarten BaertAdministrator |
Comment #87: Thu, 1 Nov 2012, 15:20 (GMT+1, DST) Quote: Xsonicvision
Maarten, can i show you a picture a gif of what is happening? or should i post up the codes? 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. Last modified: Thu, 1 Nov 2012, 15:22 (GMT+1, DST) |
Ruby |
Comment #88: Thu, 13 Dec 2012, 0:17 (GMT+1, DST) 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 BaertAdministrator |
Comment #89: Thu, 13 Dec 2012, 0:44 (GMT+1, DST) Quote: Ruby
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 :). |
Justinweq |
Comment #90: Thu, 31 Jan 2013, 2:43 (GMT+1, DST) 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! |
Maarten BaertAdministrator |
Comment #91: Thu, 31 Jan 2013, 14:26 (GMT+1, DST) Quote: Justinweq
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! 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 |
Comment #92: Sat, 9 Feb 2013, 0:44 (GMT+1, DST) 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 BaertAdministrator |
Comment #93: Thu, 14 Feb 2013, 2:58 (GMT+1, DST) Quote: Solarboy
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. 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: 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. Cheers! Glad to hear that :). |
Hilmy Irung Separo |
Comment #94: Sun, 28 Apr 2013, 3:13 (GMT+1, DST) 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 Last modified: Sun, 28 Apr 2013, 5:22 (GMT+1, DST) |
Maarten BaertAdministrator |
Comment #95: Sun, 28 Apr 2013, 5:20 (GMT+1, DST) Quote: Hilmy Irung Separo
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 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: 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). Last modified: Sun, 28 Apr 2013, 5:22 (GMT+1, DST) |
Hilmy Irung Separo |
Comment #96: Thu, 2 May 2013, 11:38 (GMT+1, DST) Quote: Maarten Baert
Quote: Hilmy Irung Separo
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 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: 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). yes, all of those example |
Grekepten |
Comment #97: Wed, 12 Feb 2014, 22:43 (GMT+1, DST) 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 BaertAdministrator |
Comment #98: Fri, 14 Feb 2014, 12:26 (GMT+1, DST) Quote: Grekepten
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. |
Arthur33 |
Comment #99: Sat, 31 May 2014, 15:28 (GMT+1, DST) !place_free does not work here? if keyboard_check(ord('W')) and !place_free(x,y+4) then xx=-1 *movement_speed ? |
Contramuffin |
Comment #100: Wed, 16 Dec 2015, 6:09 (GMT+1, DST) 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 BaertAdministrator |
Comment #101: Fri, 18 Dec 2015, 0:58 (GMT+1, DST) Quote: Contramuffin
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: |
Krishiv768 |
Comment #102: Thu, 1 Jun 2017, 13:42 (GMT+1, DST) How do I make the ball bounce higher than what it is.(using the rolling ball example) 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? Last modified: Thu, 1 Jun 2017, 15:12 (GMT+1, DST) |
Maarten BaertAdministrator |
Comment #103: Thu, 1 Jun 2017, 23:25 (GMT+1, DST) Quote: Krishiv768
How do I make the ball bounce higher than what it is.(using the rolling ball example) 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. |
Krishiv768 |
Comment #104: Fri, 2 Jun 2017, 9:19 (GMT+1, DST) Quote: Maarten Baert
Quote: Krishiv768
How do I make the ball bounce higher than what it is.(using the rolling ball example) 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. |
Maarten BaertAdministrator |
Comment #105: Sun, 4 Jun 2017, 2:23 (GMT+1, DST) Quote: Krishiv768
Quote: Maarten Baert
Quote: Krishiv768
How do I make the ball bounce higher than what it is.(using the rolling ball example) 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. 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 |
Comment #106: Mon, 5 Jun 2017, 7:28 (GMT+1, DST) Quote: Maarten Baert
Quote: Krishiv768
Quote: Maarten Baert
Quote: Krishiv768
How do I make the ball bounce higher than what it is.(using the rolling ball example) 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. 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 Last modified: Mon, 5 Jun 2017, 7:29 (GMT+1, DST) |
Maarten BaertAdministrator |
Comment #107: Mon, 5 Jun 2017, 21:14 (GMT+1, DST) Quote: Krishiv768
This happens http://imgur.com/1kHRihI 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. Last modified: Mon, 5 Jun 2017, 21:14 (GMT+1, DST) |
Krishiv768 |
Comment #108: Tue, 6 Jun 2017, 7:26 (GMT+1, DST) Quote: Maarten Baert
Quote: Krishiv768
This happens http://imgur.com/1kHRihI 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. Thanks. My bad the game im trying to replicate the physics of also doesn't all the ball to roll up 45 degree angles. I figured out the what angle the slopes should be and how the ball should roll up/roll down. And it works. |
Krishiv768 |
Comment #109: Wed, 28 Jun 2017, 12:15 (GMT+1, DST) So I need to make a tornado like obstacle with a conical "force" field like a magnet but in all directions. Last modified: Wed, 28 Jun 2017, 18:15 (GMT+1, DST) |
Maarten BaertAdministrator |
Comment #110: Thu, 29 Jun 2017, 0:00 (GMT+1, DST) Quote: Krishiv768
So I need to make a tornado like obstacle with a conical "force" field like a magnet but in all directions. Is that a question? I don't understand what you mean. |
Krishiv768 |
Comment #111: Thu, 29 Jun 2017, 11:41 (GMT+1, DST) Quote: Maarten Baert
Quote: Krishiv768
So I need to make a tornado like obstacle with a conical "force" field like a magnet but in all directions. Is that a question? I don't understand what you mean. Yup it's a question. I have been thinking about using ep_force... Stuff but I doubt i can make it realistic. |
Karst |
Comment #112: Tue, 22 Jun 2021, 23:25 (GMT+1, DST) 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 BaertAdministrator |
Comment #113: Thu, 8 Jul 2021, 0:21 (GMT+1, DST) Quote: Karst
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. |