• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM Built in physics question

I

Ian

Guest
So not really interested in movement but the accuracy of image angle dependent on its pos/speed of a physics object.

Simple throwable object made with bounce/friction logic('grenade')


Physics 'grenade' (no code, just physics w/ collision enabled for test):


I like having the grenade being able to roll and was wondering if anybody had some input on the rolling logic without enabling physics or would I be better off using built in physics for objects that require this.
 

GMWolf

aka fel666
Why reinvent the wheel?
Unless you are working on this to develop your own physics system, just use box2d!
 
I

Ian

Guest
Why reinvent the wheel?
Unless you are working on this to develop your own physics system, just use box2d!
Built in physics can get in the way of already made mechanics so would have to do a compatibility check


Simple collisions like a bullet wont work, easy fix but just example.

Since I wouldnt really be using the built in physics engine to its full potential, only using it for this scenario. Would it be worth it to convert
 

GMWolf

aka fel666
otherwise, you would have to store the momentum of your grenade.
upon touching the ground, calculate the force exerted tangentially to your sphere.
calculate the new rotational momentum and velocity.

its a lot of maths!
 
I

Ian

Guest
otherwise, you would have to store the momentum of your grenade.
upon touching the ground, calculate the force exerted tangentially to your sphere.
calculate the new rotational momentum and velocity.

its a lot of maths!
Indeed, thats why I was hoping if someone could pass down a practice for it lol
 

GMWolf

aka fel666
Indeed, thats why I was hoping if someone could pass down a practice for it lol
someone has: Its the built in physics!
I would recomend you switch to it if you want to use physcis in your game. there is no sense in re-writing everything!

you would be supprised by the number of games that use a physcis engine even though the game doesnt look like any physics is used! it just make the whole game a lot more robust.
 
W

Walter Munoz

Guest
someone has: Its the built in physics!
I would recomend you switch to it if you want to use physcis in your game. there is no sense in re-writing everything!

you would be supprised by the number of games that use a physcis engine even though the game doesnt look like any physics is used! it just make the whole game a lot more robust.
Has sense if he wants to add the online component in the future
 

GMWolf

aka fel666
Has sense if he wants to add the online component in the future
the server should handel all game logic, including physics. Then just send the positions and rotations to the client.
if you let clients do their own maths, then youll end up with synch issues and cheaters.
 
W

Walter Munoz

Guest
the server should handel all game logic, including physics. Then just send the positions and rotations to the client.
if you let clients do their own maths, then youll end up with synch issues and cheaters.
Do you know any short example of this? :D
 
I

Ian

Guest
someone has: Its the built in physics!
I would recomend you switch to it if you want to use physcis in your game. there is no sense in re-writing everything!

you would be supprised by the number of games that use a physcis engine even though the game doesnt look like any physics is used! it just make the whole game a lot more robust.
Sorry for the delay, up for lil over 24 hours had to sleep.

So what ive found when using physics, collision events dont work for non physics objects
[Bullet] Wall collision (GML; Place meeting) it has a collision event with enemy 'instance_destroy()':


So for now on cant use collision events on non-physics objects? Just making sure thats not just me.
If so would just stick with (for this scenario) use place_meeting / ray casts
 
Last edited by a moderator:
J

jackhigh24

Guest
place_meeting does work for physics objects hitting none physics i do it all the time, so your doing something wrong, the only things that dont work when you turn a room to physics are just a few like speed instead you have to use x += what ever for the none physics.

EDIT
here is an example i made a long time ago, so might not be the best code cant remember, but still have a look the vision cone is none physics, its attached to a physics object and detects when it passes over a the oMan object that is physics
https://www.dropbox.com/s/95uao9wtxb9jfs0/none_physics_collision.gmx.zip?dl=0
 
Last edited by a moderator:
I

Ian

Guest
place_meeting does work for physics objects hitting none physics i do it all the time, so your doing something wrong, the only things that dont work when you turn a room to physics are just a few like speed instead you have to use x += what ever for the none physics.

EDIT
here is an example i made a long time ago, so might not be the best code cant remember, but still have a look the vision cone is none physics, its attached to a physics object and detects when it passes over a the oMan object that is physics
https://www.dropbox.com/s/95uao9wtxb9jfs0/none_physics_collision.gmx.zip?dl=0
Wasnt my concern at all, collision checks via GML are fine. "Collision events" was my concern..
 

GMWolf

aka fel666
You can make your objects 'kinematic' or 'sensor' so they only trigger collision events.
 
Last edited:
S

seanm

Guest
You can use the gmlScripts collision_normal to find the collision normal, and calculate the bounce angle. Seems like you have this part down already.

After that just set a minimum horizontal speed that the grenade can move at. Don't let the grenades hspeed be less than lets say 0.5.

assuming the grenade will explode pretty quickly itll look fine.
 
J

jackhigh24

Guest
sorry mate i miss understood you from this line
So what ive found when using physics, collision events dont work for non physics objects
Wall collision (GML; Place meeting) bullet is a collision event with 'instance_destroy()':
as you said place_meeting there but then say collision event unless you do what fell666 says, but ye you generally wont be able to use collision event its not the same as place_meeting
 
I

Ian

Guest
You can make your objects 'kinematic' or 'sebsor' so they only trigger collision events.
Yeah ill do more research on in it, my previous question was just to make sure it didnt just affect me
 
Top