Destroying Instances at the wrong position in Game Maker HTML5 port

140 views Asked by At

Alright, so I have a trigger set that destroys an instance at a given position when the player collides with it, this seems to work fine on Windows, the coordinates match up and I've never had an issue. Except for when I export to HTML5, The triggers now destroy things at the wrong position, and in one case will destroy every instance along three points on the y axis, as opposed to destroying the three tiles directly below the player, which is what it is intended to do.

Is this just a side effect of using drag and drop for this function? This was left over because I didn't feel like rewriting that action in GML.

Or is it something out of my control?

2

There are 2 answers

1
Magnus Ravn On

when exporting to HTML5 there is a lot of things you need to take into account. there is an article in the GameMaker forums explaining this in detail: https://help.yoyogames.com/hc/en-us/articles/216754018-HTML5-Issues-And-Differences

there are two things that you should focus your attention on in the article 1. running the HTML file locally can give strange result and errors. of course I can't know if you are doing this, but the browser even warns you about this so it's a good idea to upload it to some site like Newgrounds and testing it there.

2.<, > And = Don't Give The Same Results. When doing comparisons in GameMaker: Studio, you should be aware that all numbers are actually treated as floating point values. So checking what appears to be an integer value may give different results on different platforms, and this is especially true of the HTML5 target which has less precision than, say, the Windows target. For example, you maybe want to check the image index of a sprite with an image speed of 0.5. you would expect that by adding o.5 each step, every second step the image_index would have an integer value... but it may not. 0.5 + 0.5 does not equal 1 with floating point maths, and it may be that 1 is actually 1.000000000001 or something, so the the expression will never return true.

also, a thing that has helped me a ton in the past is the "clean project asset compiler cache" button which is the little broom icon in the top left corner of the IDE. as the name says it clears the asset compiler cache which for me fixed a lot of problems when compiling and running in HTML5.

0
Rager On

One major problem I ran into when exporting for HTML5 was the randomize(); function. Make sure if you use it only use it once in your code. If you use it more than once weird stuff starts happening. Hope this helps.