Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

what's wrong with this code? it says' "error ; expected" "inavlid tokne ",'"

using System.Collections;

using System.Collections.Generic;

using UnityEngine;


public class Bird : MonoBehaviour

{

  Vector2 _startPosition;

  Rigidbody2D _rigidbody2D;

  SpriteRenderer _ spriteRenderer;


  void awake() 

  {

    _rigidbody2D = GetComponent<Rigidbody2D>();

    _spriteRenderer = GetComponent<SpriteRenderer>();

  }


  // Start is called before the first frame update

  void Start()

  {

    _startPosition = _rigidbody2D.position;

    _rigidbody2D.isKinematic = true;

  }


  void OnMouseDown() 

  {

    _spriteRenderer.color = Color.red;

  }


   void OnMouseUp() 

  {

    Vector2 currentPosition = _rigidbody2D.position;

    Vector2 direction = _startPosition - currentPosition;

    direction.Normalize();


    _rigidbody2D.isKinematic = false;

    _rigidbody2D.AddForce(direction * 500);


    _spriteRenderer.color = Color.white;

  }



  void OnMouseDrag() 

  {

    Vector3 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);

    transform.position = new Vector3(mousePosition.x, mousePosition.y,transform.position.z);

  }




  // Update is called once per frame

  void Update()

  {

     

  }

}

Sign In or Register to comment.