Unity 5 error apparently code

Asked

Viewed 152 times

1

I was playing this game when this problem came up

Assets/Sampleassets/2D/Scripts/Platformer2dusercontrol.Cs(2,25): error CS0234: The type or namespace name CrossPlatformInput' does not exist in the namespaceUnitysampleassets'. Are you Missing an Assembly Reference?

My code is as follows

using UnityEngine;
using UnitySampleAssets.CrossPlatformInput;

namespace UnitySampleAssets._2D
{

    [RequireComponent(typeof (PlatformerCharacter2D))]
    public class Platformer2DUserControl : MonoBehaviour
    {
        private PlatformerCharacter2D character;
        private bool jump;

        private void Awake()
        {
            character = GetComponent<PlatformerCharacter2D>();
        }

        private void Update()
        {
            if(!jump)
            // Read the jump input in Update so button presses aren't missed.
            jump = CrossPlatformInputManager.GetButtonDown("Jump");
        }

        private void FixedUpdate()
        {
            // Read the inputs.
            bool crouch = Input.GetKey(KeyCode.LeftControl);
            float h = CrossPlatformInputManager.GetAxis("Horizontal");
            // Pass all parameters to the character control script.
            character.Move(h, crouch, jump);
            jump = false;
        }
    }
}
  • 1

    When did this problem "appear"? Was the code working and then stopped working? Or was the error there from the beginning? Was this project made from scratch or copied from somewhere? I have no experience with Unity, but this post on unity3d.com suggests that this feature is not native to Unity, but part of a project or package ("sample Assets beta package" I think). Does your project use this package? The folder CrossPlatformInput is present?

  • Because the tag is like JavaScript if the code is C# ?

  • 2

    @mgibsonbr is exactly what you said, this code must be from some old tutorial or example, because this Unitysampleassests no longer exists has a good 3 years. Picking up the shaft has been native to the tool ever since. Here’s an example of how to pick up axles, it’s already in the right second. https://youtu.be/fotMn6x7aoU?t=34m45s

2 answers

1

The "Unitysampleassets" package was made available at the Unite event in 2014, in a talk on best practices for 2D games in Unity, you can download it here.

In this file you will find this script that is missing.

Lecture link (recommend): https://www.youtube.com/watch?v=HM17mAmLd7k

0

I don’t know this package Unitysampleassets. Did you ever import it? Did you delete any folder from it by accident?

To resolve this issue, you can reimport this package or stop using Crossplatforminput. Commenting on the line using UnitySampleAssets.CrossPlatformInput; and exchanging all the CrossPlatformInputManager for Input.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.