GMS 2 Porting issue to GM2 (maybe collison)

J

Jahasaja

Guest
Hi all,

I just uppgraded to GM2 and most of the porting seems to have gone fine. However, I have one issue that I am not sure why it is not working.

to prevent the player to walk through enemies all the enemies have an parent object called obj_solid. obj_solid is a completely empty object.

in the player step event i have:

Code:
 if ((h_move>0) && place_meeting(x+myspeed*h_move,y,obj_solid) and obj_solid.x>x)
or ((h_move<0) && place_meeting(x+myspeed*h_move,y,obj_solid) and obj_solid.x<x)
  {
   myspeed=0
  }
This worked well in GM1.4 however in GM2 it seems like it does not register the precise collision mask instead it is using a bounding box for the entire sprite even though all the enemies are using precise collision masks.

Thanks in advance for any help!
 
K

kevins_office

Guest
If i can suggest a re-structure of your if() statement
Code:
if (place_meeting(x+myspeed*h_move,y,obj_solid) && ((h_move>0 && obj_solid.x>x) || (h_move<0 && obj_solid.x<x))) myspeed=0;
Then you are only doing one collision check and feels cleaner to me.
I dont know enough about the rest of your code to know if the logic is correct in that if() statement, regarding the < > checks.

You said you believe all objects are using precise mask, did you open each sprite after the import to verify the conversion didn't mess them up?
The manual says that all objects, including the object calling the code, must have precise mask.
 
J

Jahasaja

Guest
Thanks, Kevin_office.

I checked all the objects and I cannot find the issue. However, when I change to position_meeting it seems to be working as before. I am not sure if that will create other issues though.
 
J

Jahasaja

Guest
I reopen this thread since position_meeting is not working as intended. Is there a known bug for place_meeting in GMS 2? It does not seem to always register the precise collision mask even though all the sprites for the objects have

"Mode: Manual
Type: Precise Per Frame
"

Or am I missing something else?
 
Top