#look in movement direction

1 messages · Page 1 of 1 (latest)

agile bay
#

transform.LookAt(transform.position+PlayerBody.velocity);

daring quiver
agile bay
#

what messes up?

daring quiver
#

Lemme film a vid

#

Here @agile bay

agile bay
#

is the rb on the same object as the script?

#

rigidbody

daring quiver
#

yep

agile bay
#

or a child?

daring quiver
#

Nope, on the scripted object

agile bay
#

i see the problem is the movement relies on your facing direction to move

#

can you try replace your move function with this - might not be the same controls you want for your game though, hard to tell

#
    {
        Vector3 MoveVector = PlayerMovementImput * Speed;
        PlayerBody.velocity = new Vector3(MoveVector.x, PlayerBody.velocity.y, MoveVector.z);

        transform.LookAt(transform.position + PlayerBody.velocity);
        Vector3 nRot = transform.eulerAngles;
        nRot.x = 0;
        nRot.z = 0;
        transform.rotation = Quaternion.Euler(nRot);

        if (Input.GetKeyDown(KeyCode.Space))
        {
            PlayerBody.AddForce(Vector3.up * Jumpforce, ForceMode.Impulse);
        }
    }```