Having an issue, first time user.

Just trying to get a handle on coding and I’m getting a pair of errors I can’t find a solutions for.

Errors:
Assets\PlayerMovement.cs(18,24): error CS0120: An object reference is required for the non-static field, method, or property ‘Transform.right’

Assets\PlayerMovement.cs(20,20): error CS1061: ‘CharacterController’ does not contain a definition for ‘move’ and no accessible extension method ‘move’ accepting a first argument of type ‘CharacterController’ could be found (are you missing a using directive or an assembly reference?)

Code

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);
}
}

Transform.right needs to be transform.right

C# is case sensitive. Transform is a class, whereas transform is the instance of that class that you actually are trying to access.

2 Likes

You are a gem thank you

also
controller.move()
should be
controller.Move()
that’s how it’s defined in the Character Controller script.

2 Likes