I want to use rigidbody.velocity and rigidbody.rotation with Vector3 but underlined RED. Help

    private Rigidbody rb;
    public float speed;
    public float turnSpeed;
    public float tilt;

    void Awake()
    {
        rb = GetComponent<Rigidbody>();
    }

    void Update()
    {
        // This is InputSystem for Gamepad
        Vector2 moveDirection = moveActionToUse.action.ReadValue<Vector2>();
        float rotationDirection = moveDirection.x;  // I want X axis Control

        transform.Rotate(0, rotationDirection * turnSpeed * Time.deltaTime, 0, Space.World);

        // X-axis Control is used for self Z-axis Control
        Vector3 movement = new Vector3(0.0f, 0.0f, rotationDirection);

        // movement.z * turnSpeed is RED !!
        rb.velocity = movement.z * turnSpeed;

        //  rb.velocity * -tilt is RED !!
        rb.rotation = Quaternion.Euler(0.0f, 0.0f, rb.velocity * -tilt);
     }

    void FixedUpdate()
    {
        if (rb != null)
        {
            rb.velocity = transform.forward * speed * Time.deltaTime;
        }
    }

I want to rotate world Y axis with rolling self Z axis.
How can I correct the RED!!

Thanks and Regards.

rb.velocity is a vector not a float, so you need to change the value which you are giving it.

2 Likes