I am testing some frogger like code whereby a frog can ride on a log as a passenger. This all works fine when moving up the screen at 0 degrees. See image below:

However if the Frog moves down the screen and tries to 'ride' the log the following happens:

These are the scenes for the Frog(player) and log: Log.

Frog(player).

This is the simple script to move the log from right to left and back on the Right hand side.

And this is the script to move the Frog(player). And....

I use an _On_area2d_entered() Signal to trigger when the frog is first on the platform and an exit signal for when the frog jumps off.

The part I cannot figure out is why the frog is moving in the wrong direction when facing down ( or left / right for that matter) I am sure it is to do with the rotation on the player scene but can`t work out how to remedy it.

I hope somebody can point me in the correct direction to solve this problem.

Thanks in advance.

Don't multiply delta movement by frog's basis vector. This is causing it to count in its orientation. Idealy you should multiply by log's basis but since logs are guaranteed to go along x axis you can simply change frog's x position directly:

if onPlatform:
	position.x += self.platformSpeed * delta

Thanks. I will try this out when I get back on the PC.

Thanks 'XYZ' that is working well now.

For future reference. What would the code to do the following look like?

Idealy you should multiply by log's basis

Thanks again.

@KrazyChicken said: Thanks 'XYZ' that is working well now.

For future reference. What would the code to do the following look like?

Idealy you should multiply by log's basis

if onPlatform:
    position += log.transform.x * self.platformSpeed * delta

Where log is a reference to a log sprite/node.

a year later