Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags
(3 edits)

The gist of it is that the Z value is obtained by doing a bilinear interpolation between the Z values of the 4 corners. (TLC is short for Top Left Corner, and so on). It works with rotated things as well, but the code is simplified since I'm abusing the fact everything is parallel to the X and Y axes.

Even if you rotate an object sprite_width will be its width and sprite_height will be its height, so I think the issue is that you're not computing xx/yy in "rotated space". So you'd need some code along these lines:


(where "terrain" is the ID of the slope object you want to collide with, and "player" is the player object... I don't have the source code at hand right now so I've forgotten what names are actually used in the collision logic, lol)

(The way this works is, dot product basically multiplies two vectors taking their relative alignment into account, so when one vector has length 1 the dot product will 'project' the other onto its direction... so we use this property to turn the regular x/y coordinates into coordinates relative to the rotated slope.)

The other thing that might be needed here is to make sure collisions only happen when the player is over the slope object even when it's rotated, by default Game Maker will just scale up the bounding box when you rotate something (so it is a rectangle that fully encapsulates the sprite after applying rotation) so you might trigger collisions just by being near the rotated slope since you technically collide with it.

You specifically need to have the slope object's sprite use the "rectangle with rotation" collision mode (since it is a rectangle you rotate, this is the fastest option) and probably use the "precise" flag when doing the collision checks as well - I'm not 100% sure if the rotated rectangle collision mode counts as precise or imprecise but I think it's precise.

(2 edits) (+1)

Thank you Yal you are a gem, it worked perfectly! Yeah, I've already taken care of collision with the rotated ramp (used rectangle with rotation as you mentioned), I was just missing this final piece of the puzzle.

One thing is my frame rate takes quite a hit now when walking on ramps, is dot_product just a very expensive function? 
^Disregard - my collision code was causing a bottleneck.

Thanks again!

No problem, glad it worked out so quickly!

Dot product is a very simple operation, it's just the sum of every vector component multiplied with the same component of the other vector (so the 2D case is 2 multiplications and 1 addition), so it should be faster than e.g. doing a geometric solution with trigonometry most of the time. The only thing it really does is tell you how parallel two vectors are, but it's the best choice if you need that exact thing!

Hello, I'm from Poland. I'm currently playing Heart of ruins final Columbus.  So far I have acquired 8 weapons and 48 knowledge.

 However, I don't know how to destroy the block with blue lightning.  I also don't know how to solve the puzzles for which I have hints.  I solved one with the letters "a" "b" "y" but I don't know if it's correct because they keep flashing alternately.

 I would like to ask you to help me in this game, for which I will be very grateful.  I know you've probably forgotten about this game, but I hope you'll remember something

 Regards

 My email is arko.jr@gmail.com