On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags
(1 edit)

Edit: I've just seen that you used Godot for your game and not Unity so what I posted here might not make much sense!

Hi. There isn't any calculation going on, I just rotate the transform while moving it forward:

In Update: transform.Rotate(0, 0, RotationSpeed * rotationDirection * Time.deltaTime);

rotationDirection is either -1 or 1 for left/right. It's the same for enemies and the player. 

(forward)movement is similar:

gameObject.transform.position += new Vector3(MovementSpeed * 0.1f, 0, 0).Rotate(transform.rotation.eulerAngles.z + 180);

Note: Rotate() is an extension, I post it below.

I also have the rigidbody set to kinematic (since I don't need it to be affected by physics. I only have it for Collision events.)

Rotate extension:

public static Vector2 Rotate(this Vector2 v, float degrees)
    {
        float sin = Mathf.Sin(degrees * Mathf.Deg2Rad);
        float cos = Mathf.Cos(degrees * Mathf.Deg2Rad);

        float tx = v.x;
        float ty = v.y;
        v.x = (cos * tx) - (sin * ty);
        v.y = (sin * tx) + (cos * ty);
        return v;
    }