Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question I wrote some code but Unity is giving me errors. Can someone tell me how to fix this?

Discussion in 'Scripting' started by Deleted User, May 23, 2020.

  1. Deleted User

    Deleted User

    Guest

    This is my code. Please let me know of any fixes. Thank you!!

    using System.Collections;
    using System.Collections.Generic;
    using System.Security.Cryptography;
    using System.Threading;
    using UnityEngine;

    public class PlayerMovement : MonoBehaviour{
    public float moveSpeed = 5f;
    // Start is called before the first frame update
    void Start()
    {

    }
    // Update is called once per frame
    void Update()
    {
    Vector3 movement = new Vector3(input.GetAxis("Horizontal"), 0f, 0f);
    transform.position += movement * Timeout.deltaTime * moveSpeed;
    }
    }

    (This code is for movement)
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,971
  3. ProntName

    ProntName

    Joined:
    Apr 27, 2020
    Posts:
    15
    “Time.deltaTime” instead of “Timeout.deltaTime”

    Double check when writing code since sometimes VB will auto fill what you don’t need.

    May have something to do with the namespaces (“using” lines) up at the top of your code. Do you need them all?

    I would also separate out the getting input of the axis to its own line for readability. Will be easier to debug if there are issues later.
     
  4. Deleted User

    Deleted User

    Guest

    Thank You so much!