How do I get a game object to scale up or down based on its Y position?

Here’s a math problem for you math people out there:

I have player object and enemy object in a hallway. In game, the player moves through the hallway and fights enemies along the way. As the player moves, the enemies should get closer to the player (and the background should scroll, but that’s a separate problem).

Here’s what my game currently looks like:

The enemy should scale up as it gets further down the screen, like this:

Since the player can stop and start moving, I can’t use go.animate on the enemy. I would need some way to change the scale of the enemy based on it’s Y position, hence the title (or some other solution if you know any).

Nevermind, I can just update scale at the same time as the position. No need to make sure the scale depends on the position if they’re both changing at the same time every time.

1 Like