Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Math help needed for my 3D engine

A topic by Benjamin Halko created Aug 08, 2020 Views: 213
Viewing posts 1 to 1
(1 edit)

Hello.

So I am creating my own 3D engine in Gamemaker studio 2.

I am having trouble figuring out the math for how to change an objects position and size depending on it's "z" position.

This is the math I have right now:

scale = z/camera_width

xOffset = (x - (cameraX+cameraWidth/2))*scale

yOffset = (y-cameraY)*scale

xDraw = x*(scale+1)+xOffset

yDraw = y*(scale+1)+yOffset

xScale = scale+1

yScale = scale+1

(xDraw / yDraw is where to draw the object and xScale / yScale is the size of the object)

This is the video showing how it doesn't work:

What I basically need is a way to turn X,Y,Z variables in to X,Y and Size variables.

If you know the formula in order to make that work it would be greatly appreciated.

Thanks.