Hello,
I’m fairly new to Unity and am trying to make a drag and shoot system for a ball. At the moment I’ve added a physicsMaterial2D with a bounciness of 0.8 to the ball and just got it bouncing up and down on a surface. I’ve also made it so that if you click the ball, it stops where the mouse was.
using UnityEngine;
using System.Collections;
public class Drag : MonoBehaviour {
private Vector2 clickPosition,cursorPosition;
void OnMouseDown()
{
clickPosition = Camera.main.ScreenToWorldPoint (Input.mousePosition);
gameObject.transform.position = clickPosition;
}
void OnMouseDrag()
{
cursorPosition = Camera.main.ScreenToWorldPoint (Input.mousePosition);
gameObject.transform.position = clickPosition;
}
void OnMouseUp()
{
}
}
The problem is, when the ball is on the falling part of it’s cycle, and I hold down the mouse for a long time then release- the ball speeds up massively. I’m completely stumped!
Here’s a YT of the problem (no idea why it sped up):