0
\$\begingroup\$

I am getting 2 errors in my c# script.

  1. Assets\scripts\playerMovement.cs(8,5): error CS0118: 'PlayerControls' is a namespace but is used like a type
  2. Assets\scripts\playerMovement.cs(4,19): error CS0234: The type or namespace name 'InputSystem' does not exist in the namespace 'UnityEngine' (are you missing an assembly reference?)

playerMovement.cs:

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

public class playerMovement : MonoBehaviour
{
    PlayerControls controls;
    Vector2 move;
    void Awake()
    {
        controls = new PlayerControls();

        controls.Gameplay.move.performed += ctx => move = ctx.ReadValue<Vector2>();
        controls.Gameplay.move.canceled += ctx => move = Vector2.zero;
    }
    void Update()
    {
        Vector2 m = new Vector2(move.x, move.y) * Time.deltaTime;
        transform.Translate(m, Space.World);
    }
}

I am using the new Input System 0.2.1 in unity 2018.4.25f.

The PlayerControls script is auto-generated from an Actions Input object, and it is in the main root "Assets".

\$\endgroup\$
  • \$\begingroup\$ We'll need to know more about how you set up your project to cause this problem. Which version of the Input System package do you have installed? What is this PlayerControls class you're referencing, and where does it come from? Please ensure your question contains a Minimal Complete Verifiable Example - everything we'd need to reproduce the problem when starting from a new, empty project. \$\endgroup\$ – DMGregory Aug 4 at 18:43
  • \$\begingroup\$ Hows that @DMGregory? \$\endgroup\$ – Christopher Maennche Aug 4 at 18:48
  • \$\begingroup\$ I'd recommend using an up-to-date version of Unity (2020) and the non-preview release of the Input System (1.0.0) \$\endgroup\$ – DMGregory Aug 4 at 18:57
  • \$\begingroup\$ @DMGregory I use 2018.4 because it runs better on my pc. Would you have any suggestions on how to make 2019-2020 work better on my pc? \$\endgroup\$ – Christopher Maennche Aug 4 at 18:59
  • \$\begingroup\$ That's a different question. I don't know what problems you have with those versions, so I can't advise what you'd need to do to fix them. \$\endgroup\$ – DMGregory Aug 4 at 19:01
0
\$\begingroup\$

I had to switch over to Unity 2019. Thanks for your help Everyone!

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.