create account

Playing around with Physics - GM:S 2 build in engine by mproxima

View this thread on: hive.blogpeakd.comecency.com
· @mproxima ·
$20.38
Playing around with Physics - GM:S 2 build in engine

![sdn.png](https://files.peakd.com/file/peakd-hive/mproxima/23vsLX9xmKADpfnr9WevaPfDMGKzAzPFxNNwQabUfcjrv9DJXCZ88MZ6annV9318a8gFr.png)

I always wanted to make a game with really good physics interaction that give the player many route to solve the challenges or just to have fun in the world and experiment with interactions but my expirience stopped at Little Big Planet editor because when I tried in other engines I got stuck because I was missing the basics of coding and integrating with the usually cpu stressing physics interactions was a too steep learning curve.

Yesterday I gave it a try again with GM:S 2 built in engine and to my surprise not only my ability of coding a cursor that can interact with world took only a few minutes and some tweaks from the ones I used in other non physics based games but also the built in engine works so much better then it used too. I stressed it by spawning tons of objects and it get only some dips in framerate. I'm really happy and excited about this because some game ideas I have dosen't even require a fractions of what I tested here.

**BOUNCY STUFF**

https://youtu.be/76NnQkv4nwU

**A Small Guide**

The process of making these physics interaction work is really easy, the only problem come on how Game Maker handles the code run invisible to my eyes so probably you will get into some later problems down the line. Having a written and editable code is always better but that's something I 'll look into future.

**Acivating Room Physics**

The first step is the easiest one, just go in the Room menu settings and flag Enable Physics

Here you can choose the global gravity settings, keeping in mind that Pixel to meters is a ratio that is gonna interact with Gravity x and Gravity Y

![roomphys.png](https://files.peakd.com/file/peakd-hive/mproxima/Eo45n4wXmJXcRoXNC6NPYEKXD7eqdoxiRt6rgf5AmoqHNACtfnLu97qrviQehZsZVMR.png)

**Creating the objects**

After having the physics enabled one can already start building the objects to populate the world.
Here I made the wall collision by using a simple rectangular sprite and setting his density to 0 so that would remove the gravitational pull and make it a static object.

![wall.png](https://files.peakd.com/file/peakd-hive/mproxima/23t76y5J81h9rkudvBQ5Gx3f3eNjGE43hu7V6oRsr5So8EdrATAcdxzefsTiBHxESSeWK.png)


**Collision Mask**

Remember that when using the built in Physic engine the old sprites collision masks don't work anymore instead you have to make new one in the Object>Physics menu by clicking down on the Modify Collision Shape.(Works even better and more accurate then the other one)


![balll.png](https://files.peakd.com/file/peakd-hive/mproxima/23swgShsXq8GRoZ6ri18TASy9KDGLdaqRhTR6WxxZqgg1qAaBJEzhjzUuj9kK1kUAKXcG.png)

**Proprieties and Colliding Objects**

To have the objects interact with each other you have first to flag the Uses Physics in the main object menu and then you can just add an empty event with the object you want to collide with and you are already set.
Then you can change the parameters to make different kind of objects. To make this heavy wooden ball I cranked way too up the density(just with 10 density look already like it) and made it with very little restitution upon bouncing off another object.

![woden.png](https://files.peakd.com/file/peakd-hive/mproxima/23swfuMRgrG27pJ1kEUkhPdsbWwmtoL3D8wqVrCtUSnUQM33v9Cq1YYWQLFaMAL9nvpVT.png)



**Player Interaction**

Then I made a mouse cursor to interact with the world, I made two actually one that is not a Physic object as you can see in the video earlier in the post wich is used just to spawn other stuff with the some code as below. Then I made a duplicate of that one but with activating Physics. I gave it a lot of density so it could push other objects around but it dosen't fall under gravity because I have swapped the code:

x = mouse_x
y = mouse_y

wich make an object float at the mouse coordinates but wont work with Physics object.
So I changed into this using built in variables:

phy_position_x = mouse_x
phy_position_y = mouse_y

wich nullifies the law of gravity for the object keeping it at mouse coordinates. 



![mouse.png](https://files.peakd.com/file/peakd-hive/mproxima/23swgSfP5u5uWMSPmm7HJudpgb8MVfDnPo13naf22pPcW5e6XdcFGrUwJVgff8xTQXs4G.png)

Here below you can see the showcase of the physics based mouse cursor, still I have to find a way to keep it more steady.

<iframe width="560" height="315" src="https://3speak.tv/embed?v=mproxima/xifcyonx" frameborder="0"  allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

Have a goodday!😁



👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 40 others
properties (23)
authormproxima
permlinkplaying-around-with-physics-gms-2-build-in-engine
categoryhive-176981
json_metadata"{"app":"peakd/2021.05.5","format":"markdown","description":"Physics interaction tutorial","tags":["game-design","blockchain","gaming","pixelart","palnet","creativecoin","physics"],"users":[],"image":["https://files.peakd.com/file/peakd-hive/mproxima/23vsLX9xmKADpfnr9WevaPfDMGKzAzPFxNNwQabUfcjrv9DJXCZ88MZ6annV9318a8gFr.png","https://files.peakd.com/file/peakd-hive/mproxima/Eo45n4wXmJXcRoXNC6NPYEKXD7eqdoxiRt6rgf5AmoqHNACtfnLu97qrviQehZsZVMR.png","https://files.peakd.com/file/peakd-hive/mproxima/23t76y5J81h9rkudvBQ5Gx3f3eNjGE43hu7V6oRsr5So8EdrATAcdxzefsTiBHxESSeWK.png","https://files.peakd.com/file/peakd-hive/mproxima/23swgShsXq8GRoZ6ri18TASy9KDGLdaqRhTR6WxxZqgg1qAaBJEzhjzUuj9kK1kUAKXcG.png","https://files.peakd.com/file/peakd-hive/mproxima/23swfuMRgrG27pJ1kEUkhPdsbWwmtoL3D8wqVrCtUSnUQM33v9Cq1YYWQLFaMAL9nvpVT.png","https://files.peakd.com/file/peakd-hive/mproxima/23swgSfP5u5uWMSPmm7HJudpgb8MVfDnPo13naf22pPcW5e6XdcFGrUwJVgff8xTQXs4G.png"]}"
created2021-06-06 10:28:51
last_update2021-06-06 10:28:51
depth0
children6
last_payout2021-06-13 10:28:51
cashout_time1969-12-31 23:59:59
total_payout_value9.938 HBD
curator_payout_value10.441 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length4,627
author_reputation35,190,365,212,225
root_title"Playing around with Physics - GM:S 2 build in engine"
beneficiaries
0.
accountpeakd
weight500
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id104,164,418
net_rshares33,076,275,884,266
author_curate_reward""
vote details (104)
@adamada ·
!discovery 25
properties (22)
authoradamada
permlinkre-mproxima-qufzff
categoryhive-176981
json_metadata{"tags":["hive-176981"],"app":"peakd/2021.06.2"}
created2021-06-09 16:06:51
last_update2021-06-09 16:06:51
depth1
children0
last_payout2021-06-16 16:06:51
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length13
author_reputation294,997,802,391,230
root_title"Playing around with Physics - GM:S 2 build in engine"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id104,232,668
net_rshares0
@discovery-it ·
<div class="pull-left">https://cdn.steemitimages.com/DQmTAn3c753LR7bHCLPo96g9UvRMaPFwaMYn8VQZa85xczC/discovery_logo_colore%20-%20Copia.png</div><br> This post was shared and voted inside the discord by the curators team of <a href="https://discord.gg/cMMp943"> discovery-it</a> <br>Join our community! <a href = "https://hive.blog/trending/hive-193212"> hive-193212</a><br>Discovery-it is also a Witness, vote for us <a href = "https://hivesigner.com/sign/account-witness-vote?witness=discovery-it&approve=true"> here</a>  <br>Delegate to us for passive income. Check our <a href = "https://hive.blog/hive-193212/@discovery-it/delegations-program-80-fee-back"> 80% fee-back Program</a> <hr>
properties (22)
authordiscovery-it
permlinkre-mproxima-fl9c7ci69x
categoryhive-176981
json_metadata"{"app": "beem/0.24.19"}"
created2021-06-09 16:07:12
last_update2021-06-09 16:07:12
depth1
children0
last_payout2021-06-16 16:07:12
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length690
author_reputation67,497,022,794,666
root_title"Playing around with Physics - GM:S 2 build in engine"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id104,232,671
net_rshares0
@enjar ·
Physics can be a trick thing from my understanding. Outside of a couple of strange bugs regarding it that I’ve dealt in my own game I tend to stay away from it. 

Glad you are having some fun and learning. 
👍  
properties (23)
authorenjar
permlinkre-mproxima-qubc8d
categoryhive-176981
json_metadata{"tags":["hive-176981"],"app":"peakd/2021.05.5"}
created2021-06-07 03:55:27
last_update2021-06-07 03:55:27
depth1
children2
last_payout2021-06-14 03:55:27
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length206
author_reputation1,194,220,951,992,707
root_title"Playing around with Physics - GM:S 2 build in engine"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id104,179,329
net_rshares13,235,179,300
author_curate_reward""
vote details (1)
@mproxima ·
Yeah I think for a one man project like yours, rpg nonetheless is best. In all my previus games I stayed far away from lifelike physic interaction cause the take the development into a whole other direction. Now I'm thinking about a small game using them because it would be a lot more working around situations that are really easy to take without accurate physics.
properties (22)
authormproxima
permlinkre-enjar-quco2g
categoryhive-176981
json_metadata{"tags":["hive-176981"],"app":"peakd/2021.05.5"}
created2021-06-07 21:08:42
last_update2021-06-07 21:08:42
depth2
children0
last_payout2021-06-14 21:08:42
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length366
author_reputation35,190,365,212,225
root_title"Playing around with Physics - GM:S 2 build in engine"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id104,195,596
net_rshares0
@mproxima ·
I meant complex instead of accurate.
properties (22)
authormproxima
permlinkre-enjar-quco3y
categoryhive-176981
json_metadata{"tags":["hive-176981"],"app":"peakd/2021.05.5"}
created2021-06-07 21:09:36
last_update2021-06-07 21:09:36
depth2
children0
last_payout2021-06-14 21:09:36
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length36
author_reputation35,190,365,212,225
root_title"Playing around with Physics - GM:S 2 build in engine"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id104,195,605
net_rshares0
@hivebuzz ·
Congratulations @mproxima! You have completed the following achievement on the Hive blockchain and have been rewarded with new badge(s) :

<table><tr><td><img src="https://images.hive.blog/60x70/http://hivebuzz.me/@mproxima/upvotes.png?202106091347"></td><td>You distributed more than 49000 upvotes.<br>Your next target is to reach 50000 upvotes.</td></tr>
</table>

<sub>_You can view your badges on [your board](https://hivebuzz.me/@mproxima) and compare yourself to others in the [Ranking](https://hivebuzz.me/ranking)_</sub>
<sub>_If you no longer want to receive notifications, reply to this comment with the word_ `STOP`</sub>

properties (22)
authorhivebuzz
permlinkhivebuzz-notify-mproxima-20210609t141205000z
categoryhive-176981
json_metadata{"image":["http://hivebuzz.me/notify.t6.png"]}
created2021-06-09 14:12:03
last_update2021-06-09 14:12:03
depth1
children0
last_payout2021-06-16 14:12:03
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length634
author_reputation369,400,771,956,148
root_title"Playing around with Physics - GM:S 2 build in engine"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id104,230,726
net_rshares0