using UnityEngine; using System.Collections; using UnityEngine.UI; public class gametest : MonoBehaviour { // Use this for initialization private Rigidbody2D myBody; private int didclick=0; public int speed; public float temp; public Text aa; void Awake () { myBody = GetComponent (); } // Update is called once per frame void FixedUpdate () { _mybodymove (); } void _mybodymove(){ if (didclick == 0) { transform.rotation = Quaternion.Euler (0, 0, Mathf.Sin (Time.time * speed) * 90); } else { speed=0; transform.rotation = Quaternion.Euler (0, 0,temp); } if (didclick == 1) { //didclick = 0; myBody.velocity = new Vector2(transform.position.x - myBody.position.x, transform.position.y - myBody.position.y); //speed=0; temp = Mathf.Sin (Time.time * speed) * 90; } else { //myBody.velocity = new Vector2 (0, 0); } } public void _didclick(){ didclick = 2; } }