Hi - I'm working on a top down game that uses click-to-move controls. There are large moving boats in my game and I'm trying to figure out how I can get my player to move to a certain location on the large boat, while the boat is moving.
I figured out a hack solution, where I calculated the displacement from the boats position to where I clicked to move to on the boat.
XDisplacement: (target.x - boat.x)
YDisplacement: (target.y - boat.y).
Then I move my player to this new position every tick
X: Boat.X - XDisplacement
Y: Boat.Y - YDisplacement
This keeps up to date the relative position on the boat that I ordered my player to moveTo, even if the boat is moving.
Here's an example of how it currently looks (but it's fairly odd) - https://i.imgur.com/l4onOBZ.gifv
There's a parabola effect I am trying to get rid of. Preferrably I'd like the player to move in a direct route toward the "new" location on the boat. The speed of the boat, and the speed of the player are both constant.
Does anyone have any other ideas on how this can be achieved?
Thanks in advance!