transform.forward always returns (0,0) on x and y axis.

void FixedUpdate()
    {

        if(Input.GetKeyDown(KeyCode.A))
        {
            if(isGrounded)
            {
                rb.velocity = Vector2.up * jumpForce;
            }
        }

        if(Input.GetKey(KeyCode.S))
        {
            if(!isGrounded)
            {
                Debug.Log(transform.forward.x + " " + transform.forward.y);
                rb.position = transform.forward * Time.deltaTime * boostForce;
            }
        }

    }

It’s a pretty simple code. If you’re not on the ground and you press S, you should be boosting towards the direction the character is going to. But whenever I do this, it returns 0,0 and it makes my code not work obv which is frustrating me.

Attached is something that works. I say something because you don’t talk about exactly how it should work. Here are some thoughts:

Don’t hard code KeyCode values into your script, use the input manager so that players can re-map them later.

Check for key presses in Update (this is when Unity checks) not FixedUpdate.

Use RigidBody.MovePosition to move a rigid body a fixed amount. (It will look much nicer if you apply a force).

If you have not moved your object it will be facing (0,0,1) (remember y is up, x is right), so without rotation your code will return 0,0.

6078642–659508–jump.unitypackage (4.18 KB)