Pages: 1
  Print  
Author Topic: Collision gives different results in GM8 than in Enigma  (Read 8257 times)
Offline (Unknown gender) Talkashie
Posted on: March 02, 2019, 04:40:24 am
Member
Joined: Mar 2019
Posts: 1

View Profile
I ported a GM8 project over to Enigma to see how it would work and noticed that, while the game runs just fine, collision detection was all but broken when using the same settings (precise collision checking) on Enigma. Switching to Rectangle collision checking seems to have fixed this issue for now, but this has me worried. Is this a common issue with Enigma?

I am using place_meeting for collision detection on build 1.8.40 on Linux Mint.

Could this be related to this line in the GM Incompatibilities page?
"In GM values < 0.5 are treated as false, in C++ only a value equal to 0 is treated as false. Watch out for this affecting functions that return instance like if (instance_place) and if( collision_line) you should use a != noone check with them in enigma."
Thanks for the help!
« Last Edit: March 02, 2019, 04:44:40 am by Talkashie » Logged
Offline (Unknown gender) impo
Reply #1 Posted on: March 02, 2019, 08:40:20 am
Member
Joined: Feb 2019
Posts: 15

View Profile
if rectangle collision seems to be insufficient for you, you can turn on precise collision checking, and change all of the sprite masks from rectangle primitive to precise. that should fix the problem
Logged
Offline (Male) Goombert
Reply #2 Posted on: March 09, 2019, 02:57:34 pm

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 2993

View Profile
Hi Talkashie! impo's advice is one way to go/thing to try. Regarding the boolean cast issue, that used to be a bigger incompatibility than it is now. Yes, it's true that C++ casts booleans differently than the old GML. In fact, most programming languages cast booleans the way C99 did (I mean C#/Java/etc).
Quote from: ISO C99 ยง 6.3.1.2
When any scalar value is converted to _Bool, the result is 0 if the value compares equal to 0; otherwise, the result is 1.

Now, it's no longer as much of an incompatibility, because I changed the collision functions to have a special return type, that when cast to boolean will give the expected behavior of older GM versions. I brought this to ENIGMA for the same reasons YoYo, at some point, did it for GMSv1.4. Additionally, our variant data type has always cast to boolean the way classic GM did. So, these days, in ENIGMA, unless you literally declare your variable with the [snip]bool[/snip] data type, you will get the expected behavior of older GM versions.
https://github.com/enigma-dev/enigma-dev/pull/1218

For these reasons, I have now actually updated the wiki page you were referring to. It now more accurately mentions that we have dealt with the collision functions and there shouldn't be incompatibilities here now.
https://enigma-dev.org/docs/Wiki/GM_Incompatibilities#Coding_Incompatibilities
Quote from: ENIGMA Wiki
In GM values < 0.5 are treated as false, in C++ only a value equal to 0 is treated as false. ENIGMA's variant type and instance type (returned by collision functions) have special boolean casting rules so that they give the expected results of earlier GameMaker versions when tested in conditional statements.
« Last Edit: March 09, 2019, 03:12:00 pm by Goombert » Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Pages: 1
  Print