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 namespace
Unitysampleassets'. 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;
}
}
}
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?– mgibsonbr
Because the tag is like
JavaScript
if the code isC#
?– DiegoAugusto
@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
– Nils