• Hey! Guest! The 39th GMC Jam will take place between November 26th, 12:00 UTC and November 30th, 12:00 UTC. Why not join in! Click here to find out more!

Legacy GM Problem with the draw_sprite_pos() function


Hi there,

I would really appreciate some help with draw_sprite_pos() I'm having. What I'm trying to achieve is a fake 3D effect and so far everything works just fine except that the sprite that is transformed ends up looking weird and not being transformed/scaled properly.

Here is a screenshot

Also, I've tried looking around the old forums and found a topic with a similar problem, though I couldn't really understand the solution. Link to the topic

If you could please explain or provide an example of the solution, I'd be really thankful!



Hi and welcome to the GMC!

The issue you're having is a typical limitation of affine transformations.
The solution by it is using projective transformations.

Here's the problem in a nutshell:
When GameMaker uses draw_sprite_pos, it divides the sprite into 2 triangles.
It then transforms the triangles to fit your quadrilateral by using affine transformations.

However, as you can see, this method is not fit for mimicking 3D effects.
Projective transformations are though.

What does this mean in GameMaker?
You'll have to use 3D, as that's when projective transformations are used to do these kind of things.

I don't have a lot of experience with 3D in GameMaker, so I'm not sure how you'd best do this, but I do know it is the best way to go.
There are other ways around it, by for example splitting your sprite up in many many triangles,
so that you have a lot of control over how it looks (this can be very slow),
or by using shaders (which would likely almost be the same as using 3D directly),
but I'd suggest you first try to look how to use GameMaker's 3D for solving this issue.


jo-thisjs thanks a lot for your reply, I really appreciate your help and better understand the problem now.

I want to avoid 3D functions, so I think I will experiment with splitting the sprite or shaders. :)