Basicly im trying to finally build my game but error CS0246 keeps popping up, I look in my scripts and its all correct and everything is name correctly with no spelling mistakes, iv refreshed it and cleaned and reimported my assets however nothing is seeming to work and its not even showing and error when i go into the script its just popping up in console when i try to build the game.
if someone knows how to fix this i would love some help its a 2D game and the script that isnt working is for a CharacterController2D.
perhaps you could share the full error and the code (in code tags) most of us dont memorise error numbers, and wont feel inclined to google it for you, without the code to go with (note it will tell you where and what is wrong)
Assets\Scripts\PlayerMovement.cs(9,12): error CS0246: The type or namespace name ‘CharacterController2D’ could not be found (are you missing a using directive or an assembly reference?)
and the code is
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System;
public class PlayerMovement : MonoBehaviour
{
public CharacterController2D controller;
public Animator animator;
public GameOver GameOverScreen;
public float runSpeed = 40f;
float horizontalMove = 0f;
bool jump = false;
bool crouch = false;
void Update()
{
horizontalMove = Input.GetAxisRaw(“Horizontal”) * runSpeed;
animator.SetFloat(“Speed”, Mathf.Abs(horizontalMove));
if (Input.GetButtonDown(“Jump”))
{
jump = true;
animator.SetBool(“IsJumping”, true);
}
if (Input.GetButtonDown(“Crouch”))
{
crouch = true;
} else if (Input.GetButtonUp(“Crouch”))
{
crouch = false;
}
}
public void OnLanding()
{
animator.SetBool(“IsJumping”, false);
}
void FixedUpdate()
{
// Move Our Character
controller.Move(horizontalMove * Time.fixedDeltaTime, crouch, jump);
jump = false;
}
}
Dont really know what a code tag is mate only started all of this like 2 weeks ago
and the CharacterController2D is just to make it so the Player can move its only a 2D game so its only got basic left and right movement so the code is not that complicated but i have no clue why this error is happening
yup and i have no clue what it hates because when i delted the script as all it would do is stop animations and i would be able to fix that it ened up stoping movement completely and i have no clue why
well as the person with only the text on this thread to go by, how would you expect any of us to know? but the above script looks like it used the controller to move… so, no, it probably doesnt now cos there is no controller to move it…
Ive no idea what your 2d controller script was or where you found it, or anything because you havent shared…