Jump to content
Message added by TopicLocker3000

This topic was automatically locked after 6 months of inactivity. If you are the topic owner, please contact a moderator to have it unlocked.

Recommended Posts

 

This is a pretty hard thing to do with GameMaker but none the less its possible. 

Example

iT47qbc.png

 

Physical Bodies:

A soft body accepts deformation unlike a rigid body which denies it. There for when a rigid body falls, it rolls off of other objects still holding it's shape.

Animated-Swinging-Final3.gif

Rigid body example.

de.gif

Soft body example.

 

How to set up a dynamic body

Creating a dynamic body

 

The Glorious David I intend you to use this but I'm sure you have to adjust this to your standards or your set up variables but I hope it helps.

 

Other people can use this to (I made it tutorial style to help people. xD Enjoy.

Creating dynamic bodies is almost the same as creating static bodies. There is one extra argument for dynamic bodies: norotation. If norotation is true, the rotation of the body will not be influenced by other bodies (because the moment of inertia of the body is infinite).

 
 

 

 
body = ep_body_create_dynamic(global.world,false);

// false: this body can rotate.

You have to set the center of mass, mass and moment of inertia of the body before you can use it. The easiest way to do this is calling ep_body_calculate_mass. This function will calculate the center of mass, mass and moment of inertia of the body based on the shapes you have added to the body.

    

 

 

// call this function after adding the shapes:
ep_body_calculate_mass(global.world,body);

Circle shapes

You can create circle shapes in the same way you create box shapes:

    

 

 

shape1 = ep_shape_create_circle(global.world,body,32,0,0,0,1);
// 32: the radius of the circle.
// 0,0,0: the relative coordinates of the shape (x,y,rot).
// 1: the density of the circle (not used for static bodies).

Polygon shapes

Creating polygon shapes is more complicated.(such as a torch or player), because you have to create a polygon first. A polygon can be used by multiple bodies, so usually you can create all polygons immediately after creating the world.

    

 

 

global.poly_triangle1 = ep_polygon_create(global.world,3);
// 3: number of vertices.
ep_polygon_set_vertex(global.world,global.poly_triangle1,0,-10,-10);
// 0: first vertex.
// -10,-10: coordinates of the vertex.
ep_polygon_set_vertex(global.world,global.poly_triangle1,1,+10,+10);
// 1: second vertex.
// +10,+10: coordinates of the vertex.
ep_polygon_set_vertex(global.world,global.poly_triangle1,2,-10,+10);
// 2: third vertex.
// -10,+10: coordinates of the vertex.
ep_polygon_initialize(global.world,global.poly_triangle1);

There are two things you have to take in mind:

  • Vertices have to be declared in clockwise order (in a left-handed coordinate system).

  • All polygons have to be convex. If a body is concave you have to create multiple convex polygons. You can use multipolygons to accomplish that.

    

 

 

shape1 = ep_shape_create_polygon(global.world,body,global.poly_triangle1,0,0,0,1);
// global.poly_triangle1: the id of the polygon.
// 0,0,0: the relative coordinates of the shape (x,y,rot).
// 1: the density of the polygon (not used for static bodies).
    

 

 

Note

You can't destroy a polygon if it's still in use.

Simulating

You have to call ep_world_update_contacts and ep_world_simulate_step to simulate one step. Usually this is done in the end step event of the controller.

    

 

 

ep_world_update_contacts(global.world);
ep_world_simulate_step(global.world);

After simulating a step you have to update the position and orientation of the objects in Game Maker to see the results of the simulation. This is usually done in the end step event of the objects.

    

 

 

x = ep_body_get_x(global.world,body);
y = ep_body_get_y(global.world,body);
image_angle = radtodeg(ep_body_get_rot(global.world,body));   

 

Tip you should probably destroy the object/player after leaving the room. Okay :)    

Edited by x33perking
Link to post
Share on other sites

There is new things that will allow things like this to happen. Example, it would only take to keyframes to make a block drop, and then start bouncing as if when it hit, had momentum, and went back up, then down, then up a little, then down, then up even less, then eventually not move. 2 keyframes.

Example image

QZ4ewko.png

Yah but I'm talking about changing the collision shape. D:< Lol ^_^

Link to post
Share on other sites

I think that's way to hard to code, and way too many (what's the technical term),,

cause if a block of wood for example has to break down pixel by pixel the program will have to create those blocks and that's hard try imagining a 16x16 pixel block and break it down to 1x1 you got 256 blocks to create, o_o

Link to post
Share on other sites

I think that's way to hard to code, and way too many (what's the technical term),,

cause if a block of wood for example has to break down pixel by pixel the program will have to create those blocks and that's hard try imagining a 16x16 pixel block and break it down to 1x1 you got 256 blocks to create, o_o

 

Often times, people look at coding the wrong way and think of it in a far more literal sense. If you're not sure about how coding works, just please don't bring it up.

Creating all these subparticles would be relatively easy. Rendering said subparticles would be easy. Determining where to actually move these subparticles, and physics in general, would be tricky. But really, it's all really just maths. Lots of it.

Also, the blocks are 3D, so it would be 4096 subparticles.

Edited by Poyoarya
Link to post
Share on other sites

 

Often times, people look at coding the wrong way and think of it in a far more literal sense. If you're not sure about how coding works, just please don't bring it up.

Creating all these subparticles would be relatively easy. Rendering said subparticles would be easy. Determining where to actually move these subparticles, and physics in general, would be tricky. But really, it's all really just maths. Lots of it.

Bro you speak my language. :D BEST BUDS FOR LIFE!

Link to post
Share on other sites

I think that's way to hard to code, and way too many (what's the technical term),,

cause if a block of wood for example has to break down pixel by pixel the program will have to create those blocks and that's hard try imagining a 16x16 pixel block and break it down to 1x1 you got 256 blocks to create, o_o

It doesn't have to break it could just bounce and mush.

Link to post
Share on other sites

In order for The Glorious David to create this, it would require every single item in the program (blocks, items, characters, etc.) to be made of thousands of micro-pixels.

In conclusion

This idea = difficult to create for mineimator

 

 

This could possibly be added in 3 to 5 years, but it's still even unlikely for that amount of time, because

davd = ONE PERSON

Why not just have the objects be the way they are at the moment, and then just split them up when necessary? Calculations and operations can be made on the fly, not just pre-applied and executed.

Link to post
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...