I want the sprite to make an impulse everytime I click the left button mouse but I'm getting errors from the script.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Aviao : MonoBehaviour
{
Rigidbody2D fisics;
private void Awake()
{
this.fisics = this.GetComponent<Rigidbody2D>();
}
private void Update ()
{
if(Input.GetButtonDown("Fire1"))
{
this.Impulsionar();
}
}
}
private void Impulsionar()
{
this.fisica.AddForce(Vector2.up * 10, ForceMode2D.Impulse);
}
Assets\Script\Aviao.cs(21,5): error CS8803: Top-level statements must precede namespace and type declarations.
Assets\Script\Aviao.cs(21,5): error CS0106: The modifier 'private' is not valid for this item