I am making a game that slingshots an object using a line renderer. I wanted to know how I can throw my object when I unclick my mouse without having a curve trajectory like throwing a basketball to a ring. I already coded some script that will make an object throw but with a curve.
Here's an example that I want to achieve?
RED - How I want my object to happen.
BLUE - How I don't want my object to happen.
CODE
public float power; public Vector2 minPower; public Vector2 maxPower; Vector2 force; void Update() { MouseControl(); } void MouseControl() { //When touched if (Input.GetMouseButtonDown(0)) { //CODE } //When touch is hold if (Input.GetMouseButton(0)) { //CODE } //When touch is release if (Input.GetMouseButtonUp(0)) { force = new Vector2(Mathf.Clamp(startPoint.x - endPoint.x, minPower.x, maxPower.x), Mathf.Clamp(startPoint.y - endPoint.y, minPower.y, maxPower.y)); myBody.velocity = force * power; } } 