I want to click/touch and move my object(2D) on Y axis at certain speed, and I want it so if the user clicks again the speed will not change until it touches a certain object(Line).
Basically figured it out!
using UnityEngine;
using System.Collections;
public class GameBallMove : MonoBehaviour {
public float BallMoveForce = 10f;
private Rigidbody2D rb;
private bool ballInPlay;
// Use this for initialization
void Awake () {
rb = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void Update () {
if (Input.GetMouseButtonUp(0) && ballInPlay == false)
{
ballInPlay = true;
rb.AddForce(new Vector2(0, BallMoveForce));
}
}
}