Script chodzenia w grze 2d:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Script : MonoBehaviour {
void MoveLeft()
{
this.GetComponent<Rigidbody2D>().AddForce(new Vector2(-150f, 0f));
}
void MoveRight()
{
this.GetComponent<Rigidbody2D>().AddForce(new Vector2(150f, 0f));
}
void Jump()
{
if(this.GetComponent<Rigidbody2D>().velocity.y == 0f)
{
this.GetComponent<Rigidbody2D>().AddForce(new Vector2(0f, 500f));
}
}
}
I w konsoli wyskakuje taki błąd:
Assets/Scripts.cs(6,7): error CS1525: Unexpected symbol `void', expecting `class', `delegate', `enum', `interface', `partial', or `struct'