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

public class PlayerMovement : MonoBehaviour

public CharacterController characterController;

public float speed = 5f;

public float gravity = -9.81;

public Transform groundCheck;
public float sphereRadius = 0.3f;
public LayerMask groundMask;

bool isGrounded;
Vector3 velocity;





void Update()
{

    isGrounded = Physics.CheckSphere(groundCheck.position,sphereRadius,groundMask);

    if (isGrounded && velocity.y < 0)
    {
        velocity.y = -2f;
    }

    float x = Input.GetAxis("Horizontal");

    float z = Input.GetAxis("Vertical");

    Vector3 move = transform.right * x + transform.forward * z;

    characterController.Move(move * speed * Time.deltaTime);

    velocity.y += gravity * Time.deltaTime;

    characterController.Move(velocity * Time.deltaTime);


}

Besides the poor and failed code formatting you omitted what line has the error. Also, double is a valid floating point type.

Double: The C++ double is also a primitive data type that is used to store floating-point values up to 15 digits.

  1. You didn't tell what line has the error.
  2. Extraneous blank lines.
  3. Code not in the code block.

PS: Example Double to Float at https://www.codegrepper.com/code-examples/cpp/double+to+float+c%2B%2B

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.