Page 1 of 1

How to make a graf's coords adjusted to player's position

Posted: Mon Aug 11, 2025 11:32 am
by John Nameless
So im trying to make a graf, move it's x coords at the same speed to where the player is moving, making it not able to go offscreen.

However using the solo "speedX/Y" values included is not accurate to the player speed for some reason, & using the included "x/y" values makes it vanish completely, & trying to use the v.parameter stuff seems to not make the extra-setting code set not work at all.

Is there any better method on doing the title above?

Image

Re: How to make a graf's coords adjusted to player's position

Posted: Mon Aug 11, 2025 12:27 pm
by deice
John Nameless wrote:
Mon Aug 11, 2025 11:32 am
So im trying to make a graf, move it's x coords at the same speed to where the player is moving, making it not able to go offscreen.
if i'm understanding you correctly, you want the graf to follow the player's position, right? you might want something like this:

Code: Select all

x = max(npc.sectionObj.boundary.left, min(npc.sectionObj.boundary.right - npc.width, (player.x + player.width * 0.5 - npc.width * 0.5))) - npc.spawnX;
y = 0;
just make sure to have the following inside the graf's npc config file:

Code: Select all

setpos=0
blocks=0
relativecoords=0
if you want something more involved (such as, the graf has a smooth transition to the player's x coordinate instead, or it continues moving), that's going to be more complex and might require additional lua

Re: How to make a graf's coords adjusted to player's position

Posted: Tue Aug 12, 2025 9:27 am
by John Nameless
deice wrote:
Mon Aug 11, 2025 12:27 pm
John Nameless wrote:
Mon Aug 11, 2025 11:32 am
yup that works well enough, thanks deice!