- Home /
Error CS8025
Hello guys, I got an error with my script in unity: Assets/scripts/PlayerController.cs(69,17): error CS8025: Parsing Error. Can you please help me. Sry if my english isn't so perfect. I'm from germany
public float jumpPower = 10;
bool inputJump = false;
float velocity = 0;
Vector3 moveDirection = Vector3.zero;
CharacterController characterController;
SpriteController spriteController;
// Use this for initialization
void Start () {
characterController = GetComponent<CharacterController> ();
spriteController = GetComponent<SpriteController> ();
}
// Update is called once per frame
void Update () {
InputCheck ();
Move ();
SetAnimation ();
}
void InputCheck()
{
velocity = Input.GetAxis ("Horizontal") * speed;
if (Input.GetKeyDown (KeyCode.Space)) {
inputJump = true;
}
else
{
inputJump = false;
}
}
void Move()
{
if (characterController.isGrounded)
{
if (inputJump)
moveDirection.y = jumpPower;
}
moveDirection.x = velocity;
moveDirection.y -= gravity;
characterController.Move(moveDirection *Time.deltaTime);
}
void SetAnimation()
{
if (velocity > 0) {
spriteController.setAnimation (spriteController.AnimationType.goRight);
}
if (velocity < 0) {
spriteController.setAnimation (spriteController.AnimationType.goLeft);
}
}
using UnityEngine; using System.Collections;
public class PlayerController : $$anonymous$$onoBehaviour {
public float gravity = 8;
public float speed = 10;
public float jumpPower = 10;
bool inputJump = false;
float velocity = 0;
Vector3 moveDirection = Vector3.zero;
CharacterController characterController;
SpriteController spriteController;
// Use this for initialization
void Start () {
characterController = GetComponent<CharacterController> ();
spriteController = GetComponent<SpriteController> ();
}
// Update is called once per frame
void Update () {
InputCheck ();
$$anonymous$$ove ();
SetAnimation ();
}
void InputCheck()
{
velocity = Input.GetAxis ("Horizontal") * speed;
if (Input.Get$$anonymous$$eyDown ($$anonymous$$eyCode.Space)) {
inputJump = true;
}
else
{
inputJump = false;
}
}
void $$anonymous$$ove()
{
if (characterController.isGrounded)
{
if (inputJump)
moveDirection.y = jumpPower;
}
moveDirection.x = velocity;
moveDirection.y -= gravity;
characterController.$$anonymous$$ove(moveDirection *Time.deltaTime);
}
void SetAnimation()
{
if (velocity > 0) {
spriteController.setAnimation (spriteController.AnimationType.goRight);
}
if (velocity < 0) {
spriteController.setAnimation (spriteController.AnimationType.goLeft);
}
}
I forgot some lines from the text
Answer by Landern · Aug 19, 2014 at 02:18 PM
This is typically a curly brace issue. IN the case of both your scripts posted above, you're missing an ending curly brace.
using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour {
public float gravity = 8;
public float speed = 10;
public float jumpPower = 10;
bool inputJump = false;
float velocity = 0;
Vector3 moveDirection = Vector3.zero;
CharacterController characterController;
SpriteController spriteController;
// Use this for initialization
void Start () {
characterController = GetComponent<CharacterController> ();
spriteController = GetComponent<SpriteController> ();
}
// Update is called once per frame
void Update () {
InputCheck ();
Move ();
SetAnimation ();
}
void InputCheck()
{
velocity = Input.GetAxis ("Horizontal") * speed;
if (Input.GetKeyDown (KeyCode.Space)) {
inputJump = true;
}
else
{
inputJump = false;
}
}
void Move()
{
if (characterController.isGrounded)
{
if (inputJump)
moveDirection.y = jumpPower;
}
moveDirection.x = velocity;
moveDirection.y -= gravity;
characterController.Move(moveDirection *Time.deltaTime);
}
void SetAnimation()
{
if (velocity > 0) {
spriteController.setAnimation (spriteController.AnimationType.goRight);
}
if (velocity < 0) {
spriteController.setAnimation (spriteController.AnimationType.goLeft);
}
}
}
now I get the following error: Assets/scripts/PlayerController.cs(60,42) error CS1061: Type SpriteController' does not contain a definition for
setAnimation' and no extension method setAnimation' of type
SpriteController' could be found
Vector3 moveDirection = Vector3.zero;
CharacterController characterController;
SpriteController spriteController;
Do you mean sth like this?
no, i mean if you're saying "spriteController" is of type "SpriteController" then SpriteController, the class must be defined somewhere, it's the blueprints that make up the objects that are of type SpriteController. Can you see it in your project? Unity is having issues finding it.
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
4 errors in 1 script. Unexpected symbols and more, help please? 0 Answers
Error Building Player: 'aapt.exe' Win32Exception 3 Answers
BCE0044 unexpected char: 0xFEFF 2 Answers
£ Symbol won't work on Mac? 0 Answers