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

GameMaker Room physics prevents character from moving

T

TToasterr

Guest
Okay, I am fairly new to GMS 2, but I have been messing around with it and creating a small, random game for fun. Everything works fine, up until I turn room physics on. It prevents the character from moving, and I have tried googling it but cannot find anything. Maybe i'm just being dumb?

This is how I have the movement set up:
GM Screenshot.PNG

The physics for the character:
GM Screenshot 2.PNG

And for the floor:
GM Screenshot 1.PNG

If you want to see any other part of it, Just tell me.
I also apologize, as alot of my 'coding' (DnD) is probably very clunky seeming to you, but I'm just trying to get stuff to work, not have it look nice.
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Okay, this is because the jump-to-point and other movement actions are working on a standard instance and instance variable. However when you enable physics, you are also enabling a whole host of new instance variables that DON'T currently have a DnD implimentation. FOr example, to move you should be using the physics impulse and force functions, although you can use drag and drop to set the ph_position_x and and phy_position_y variables too. So, if you are going to use physics then you'll need to use a bit of GML code, but vefore you do ask yourself if you NEED physics for the game. Enabling physics is very different to using normal instances and it may be that it won't benefit your project in the long run...
 
T

TToasterr

Guest
Okay, this is because the jump-to-point and other movement actions are working on a standard instance and instance variable. However when you enable physics, you are also enabling a whole host of new instance variables that DON'T currently have a DnD implimentation. FOr example, to move you should be using the physics impulse and force functions, although you can use drag and drop to set the ph_position_x and and phy_position_y variables too. So, if you are going to use physics then you'll need to use a bit of GML code, but vefore you do ask yourself if you NEED physics for the game. Enabling physics is very different to using normal instances and it may be that it won't benefit your project in the long run...
Thanks! What I needed it for was adding friction so the character slows down as he moves, but maybe there's another way to do that?
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Okay, so, you are moving the instance using the "jump to position" action.... which means that the instance isn't moving in a linear fashion using speed or direction (essentially you are lifting it up from one position and teleporting it to another), so friction is not going to work here anyway. If you want friction you need to move the instance by setting a speed and a direction for it, and then setting the Instance Variable "friction". You should check out what instance variables are available to you in the manual, as they can all be used in Drag and Drop the same as in GML. :)

http://docs2.yoyogames.com/index.ht...rence/instances/instance_variables/index.html
 
T

TToasterr

Guest
Okay, so, you are moving the instance using the "jump to position" action.... which means that the instance isn't moving in a linear fashion using speed or direction (essentially you are lifting it up from one position and teleporting it to another), so friction is not going to work here anyway. If you want friction you need to move the instance by setting a speed and a direction for it, and then setting the Instance Variable "friction". You should check out what instance variables are available to you in the manual, as they can all be used in Drag and Drop the same as in GML. :)

http://docs2.yoyogames.com/index.html?page=source/_build/3_scripting/4_gml_reference/instances/instance_variables/index.html
Okay, so I changed the movement system, but the problem of no movement still persists. Room physics is off, and i'm not even worried about the friction anymore. I just need him to be on the same level as the hitbox of the floor, which looks like this:
a gm 4.PNG

This is all that I have the floor set to:
a gm.PNG

And ive been googling around but cant find anything that works. Not even on the forum. The new movement system works like this:
a gm 2.PNG

And the players gravity is just set to one.
I really want to get gravity working, but I have no idea how. I apologize if im just missing something and being dumb, but ive tried googling.
 
@Nocturne if you don't mind I have a tag-along question here. I've read changing a fixture's phy_position_x and phy_position_y directly can cause issues. But I've been unable to find elaboration on that topic. Do you have any insight on that?
 

FrostyCat

Redemption Seeker
@Nocturne if you don't mind I have a tag-along question here. I've read changing a fixture's phy_position_x and phy_position_y directly can cause issues. But I've been unable to find elaboration on that topic. Do you have any insight on that?
He does, and it's all in the Manual.
The Manual entry for phy_position_x and phy_position_y said:
Please note that the physics world may present errors when instances are moved by directly setting this variable as it will interrupt the continuous simulation.
The Manual entry for the physics system's overview said:
  • Try not to move instances from one point of the room to another in any way other than using the physics functions (ie: do not set the x/y coordinates manual). Although this can be done and in some circumstances it may be necessary, this is generally to be avoided due to the unpredictable results that it may have on the physics engine, especially when trying to resolve collisions.
A lot of rookies turn on the physics system just because they think movement means physics. They should stop believing that.

What's worse, a number of YouTube tutorial authors advocate enabling the physics system and then manually setting the coordinates the whole time. Novices get mixed messages and many are now unable to tell the difference between movement with and without the physics system because of these.

The former is just part of making mistakes while starting out and I don't blame them for it, but any author advocating against well-defined best practices in the physics system should take off their related offerings and be absolutely ashamed of themselves.
 
I'm mostly interested in what circumstances you can expect it to be okay to set phy_position_x, and _y directly. The manual seems to imply that it is okay when there is no possibility of a collision being involved, but it doesn't outright say that.
 
Top