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. Dismiss Notice

i got cs1002 i don't know why

Discussion in 'Scripting' started by shockziv, Aug 25, 2020.

  1. shockziv

    shockziv

    Joined:
    Aug 25, 2020
    Posts:
    2
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class playermovement : MonoBehaviour
    {
    public CharacterController controller;

    public float speed = 12f;

    // Update is called once per frame
    void Update()
    {
    float x = Input.GetAxis("Horizontal");
    float z = Input.GetAxis("Vertical");

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

    controller.Move(move * speed * Time.deltaTime);
    }
    }
     
  2. bobisgod234

    bobisgod234

    Joined:
    Nov 15, 2016
    Posts:
    1,042
    Please use code tags and also paste the full error message (especially the line the error is on)

    https://forum.unity.com/threads/using-code-tags-properly.134625/

    The problem is this line:

    Code (CSharp):
    1. Vector3 move = transform right * x +transform.forward * z;
    You have used a space where you need a full stop: "transform right" should be "transform.right".
     
  3. shockziv

    shockziv

    Joined:
    Aug 25, 2020
    Posts:
    2
    thanks i am new to coding