• 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!

Creating physics objects in normal platformer

S

Simulacron

Guest
I want to create a platformer game with some physics objects like crates that you can push around.
My problem is to connect these things together. I'm a beginner to physics and not sure how to use them
I created a few physics objects in a room, that worked, but when I try to add my player to the level problems start.
My player uses the normal "non-physic" way to move and when I add it to the physics room it doen't move at all. However, when I enable physics I can use it normally, but then the physics objects doesn't work as expected.
Can I combine these to things together or do I need to create a player that moves with physics to get the game to work?
 
M

Misty

Guest
For some odd reason, when a room has physics it disables all the hspeed and speed variables in all non-physics objects. So you have to make a variable called hspeed2 and such.
 
S

Simulacron

Guest
For some odd reason, when a room has physics it disables all the hspeed and speed variables in all non-physics objects. So you have to make a variable called hspeed2 and such.
I tried this out, but all I get is an error message, because the game doesn't hspped to as a spped variable to set the speed in game.
 

Tornado

Member
Maybe I'm missing something here, but why don't you make object player also physics-object and then use phy_speed, phy_speed_x and phy_speed_y on it? There are also phy_position_x and phy_position_x, but it is not recommented to set the position manually for physics objects.
 
Last edited:
S

Simulacron

Guest
Maybe I'm missing something here, but why don't you make object player also physics-object and then use phy_speed, phy_speed_x and phy_speed_y on it? There are also phy_position_x and phy_position_x.
So I just programm everything as normal and just use these other variables for the speed?
 

Tornado

Member
That's the plan. For example I have a game with physics world and physics objects, but I can still control my player with virtual joystick by setting phy_speed_x and phy_speed_y. So I have the control over it and also it participates in all collisions and is also moved automatically by physics when something with similar or bigger mass bumps into it.

Edit: I corrected something here: I'm not setting position directly but using phy_speed_x and phy_speed_y.
 
Last edited:
S

Simulacron

Guest
That's the plan. For example I have a game with physics world and physics objects, but I can still control my player with virtual joystick by adding or subtracting values to/from phy_position_x and phy_position_y. So I have the control over it and also it participates in all collisions and is also moved automatically by physics when something with similar or bigger mass bumps into it.
So I managed to get the platformer movment to work with the physics_apply_force function, but my problem is that when I stop moving my character keeps sliding a few more units. Is there anyway to disable this?
 

Tornado

Member
If you want your player to stop immediatelly then maybe physics_apply_force is not the best choice for movement.

But you can try to keep it and just adjust "linear dumping" property for the player object. The bigger the value the faster the object will loose its momentum.
 
Last edited:
Top