Adding jump to a Third person 3d movement

well, 1 im new to game dev and C# in itself, ive been using some tutorials to understand that language a bit, got a working camera script and movement script, but im trying to add jump to it. I do have a vr game ive published so i know some of what im doing but still learning. This is meant to be a turn based open world rpg (similar to a dragon quest playstyle). 2. im not to sure where to go now. ive tried many things just dont know what im supposed to do.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerController : MonoBehaviour
{
    [Header("Movement Settings")]
    [SerializeField] float moveSpeed = 5f;
    [SerializeField] float rotationSpeed = 500f;

    /* set radius for ground check */
    [Header("Ground Check Settings")]
    [SerializeField] float groundCheckRadius = 0.2f;
    [SerializeField] Vector3 groundCheckOffset;
    [SerializeField] LayerMask groundLayer;

    bool isGrounded;

    float ySpeed;
    Quaternion targetRotation;

    CameraController cameraController;
    Animator animator;
    CharacterController characterController;
    private void Awake()
    {
        cameraController =  Camera.main.GetComponent<CameraController>();
        animator = GetComponent<Animator>();
        characterController = GetComponent<CharacterController>();
    }
    private void Update()
    {
        float h = Input.GetAxis("Horizontal");
        float v = Input.GetAxis("Vertical");

        float moveAmount = Mathf.Clamp01(Mathf.Abs(h) + Mathf.Abs(v));

        var moveInput = (new Vector3(h, 0, v)).normalized;

        var moveDir = cameraController.PlanarRotation * moveInput;

        var velocity = moveDir * moveSpeed;
        velocity.y = ySpeed;

        GroundCheck();
        if (isGrounded)
        {
            ySpeed = -0.5f;

            if(Input.GetButtonDown("Jump"))
            {
                velocity = 10f;
            }
        }
        else 
        {
            ySpeed += Physics.gravity.y * Time.deltaTime;
        }

        characterController.Move(velocity * Time.deltaTime);

        if (moveAmount > 0)
        {
            targetRotation = Quaternion.LookRotation(moveDir);
        }

        transform.rotation = Quaternion.RotateTowards(transform.rotation, targetRotation, rotationSpeed * Time.deltaTime);

        animator.SetFloat("moveAmount", moveAmount, 0.5f, Time.deltaTime);
    }

    void GroundCheck()
    {
        isGrounded = Physics.CheckSphere(transform.TransformPoint(groundCheckOffset), groundCheckRadius, groundLayer); 
    }

    private void OnDrawGizmosSelected()
    {
        Gizmos.color = new Color(0, 0, 1, 0.5f);
        Gizmos.DrawSphere(transform.TransformPoint(groundCheckOffset), groundCheckRadius);
    }
}

Thats what im currently at. I get a CS0029 saying

it cant be implicity convert type ‘float’ to ‘UnityEngine.Vector3’

without the jump stuff it works just fine. I want to add jumping to the game and maybe sprinting. so does anyone know how i would go about this? And any advice to learn the language better?

Edit: Sorry about forgeting the line, line 52. The jump velocity.

Can you actually tell us what line the error happens at?

In any case, you’re trying to assign a float to a Vector3 value. Obviously you can’t do that, and probably need to make a Vector3 out of said float, or assign said float to the x, y or z components of the vector.

I edited the post! Sorry forgot to include that

Right, so this line:

velocity = 10f;

As mentioned you can’t assign a float to a Vector3. You should probably double check what your intention is here. I think this is just a logic error.

Ok do you know a way to add jump then? Im trying to make it so that when the spacebar is pressed it will trigger a jump

Well what direction is up in a Vector3 value? That would be the y component. So just assign to the y component instead.

So i can use that if statement and just say to move it up by vector3(0, 10, 0)?

That or just add to the y component of the vector: velocity.y += 10f

ok ill try that

didnt seem to work. the vector gave an error and when i hit space it doesnt move up…

I found a fix. I moved it out side the first if statement and then set it to change the yspeed which is set to equal the velocity