Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question How Do I Fix This??

Discussion in 'Input System' started by Floxey08, Nov 19, 2023.

  1. Floxey08

    Floxey08

    Joined:
    Nov 11, 2023
    Posts:
    3
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    public class PlayerMovement : MonoBehaviour
    {
    //Values
    public float walkSpeed = 80f;
    private CharacterController controller;
    void Start()
    {
    controller = GetComponent<CharacterController>();
    Cursor.visible = false;
    Cursor.lockState = CursorLockMode.Locked;
    }
    void update()
    {
    float v = Input.GetAxisRaw("Vertical");
    float h = Input.GetAxisRaw("Horizontal");
    float MoveForward = v * walkSpeed * Time.deltaTime;
    float MoveToSides = h * walkSpeed * Time.DeltaTime;
    controller.Move(MoveForward);
    controller.Move(MoveToSides);
    }
    }
     
  2. APSchmidt

    APSchmidt

    Joined:
    Oct 31, 2023
    Posts:
    249
    Fix what?

    And please, use code tags when you post a script.
     
    bugfinders likes this.
  3. Floxey08

    Floxey08

    Joined:
    Nov 11, 2023
    Posts:
    3
    this error

    Assets\Scripts\PlayerMovement.cs(25,25): error CS1503: Argument 1: cannot convert from 'float' to 'UnityEngine.Vector3'
     
  4. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,279
    Assets\Scripts\PlayerMovement.cs(25,25):
    means line 25, column 25.

    Argument 1:
    means the first thing inside parentheses, or MoveForward. MoveForward is a float. The function wants a Vector3. There is no conversion between these two types. You will have to figure out what you mean, and make the appropriate fix.

    Also, you spelled your Update() function as "update()", which is a completely different spelling to computers. Unity will ignore your "update()" when it tries to call Update().
     
  5. Floxey08

    Floxey08

    Joined:
    Nov 11, 2023
    Posts:
    3
    Thank you