I am trying to make my first 2d platformer but this message pops up whenever I try to enter playmode. Any help? Keep in mind that I am not by any means an expert programmer. Here is the code causing the error below:
using UnityEngine;
[RequireComponent(typeof(PlatformerCharacter2D))]
public class Platformer2DUserControl : MonoBehaviour
{
private PlatformerCharacter2D character;
private bool jump;
void Awake()
{
character = GetComponent<PlatformerCharacter2D>();
}
void Update ()
{
// Read the jump input in Update so button presses aren't missed.
#if CROSS_PLATFORM_INPUT
if (CrossPlatformInput.GetButtonDown("Jump")) jump = true;
#else
if (Input.GetButtonDown("Jump")) jump = true;
#endif
}
void FixedUpdate()
{
// Read the inputs.
bool crouch = Input.GetKey(KeyCode.LeftControl);
#if CROSS_PLATFORM_INPUT
float h = CrossPlatformInput.GetAxis("Horizontal");
#else
float h = Input.GetAxis("Horizontal");
#endif
// Pass all parameters to the character control script.
character.Move( h, crouch , jump );
// Reset the jump input once it has been used.
jump = false;
}
}
UPDATE: I am using the 2d player animator from the free sample 2d assets from the asset store.
I’m guessing you imported the whole sample assets beta package, then deleted some of the folders? (For example, the “Cross Platform Input” folder?)
If you’re not interested in the cross-platform input features provided in the sample assets package (i.e. having touch/tilt controls mapped to Horizontal / Vertical axes, etc) and you’ve already deleted the “Cross Platform Input” folder, then you can delete those parts from your code which refer to it, leaving you with something that should look like this:
using UnityEngine;
[RequireComponent(typeof(PlatformerCharacter2D))]
public class Platformer2DUserControl : MonoBehaviour
{
private PlatformerCharacter2D character;
private bool jump;
void Awake()
{
character = GetComponent<PlatformerCharacter2D>();
}
void Update ()
{
// Read the jump input in Update so button presses aren't missed.
if (Input.GetButtonDown("Jump")) jump = true;
}
void FixedUpdate()
{
// Read the inputs.
bool crouch = Input.GetKey(KeyCode.LeftControl);
float h = Input.GetAxis("Horizontal");
// Pass all parameters to the character control script.
character.Move( h, crouch , jump );
// Reset the jump input once it has been used.
jump = false;
}
}
You Can Solve This Problem Directly
By moving new assets folder which you import to new folder
i just create folder named Import
and move Standard Assets folder to it
and every thing work correctly