Hello,
I have a problem with a ball (sphere). the ball bounces up at times. But they shouldn’t. Here’s some code. Many thanks for the help!
void Update()
{
if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began)
{
// getting touch position and marking time when you touch the screen
touchTimeStart = Time.time;
startPos = Input.GetTouch(0).position;
}
if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Ended)
{
// marking time when you release it
touchTimeFinish = Time.time;
// getting release finger position
endPos = Input.GetTouch(0).position;
// calculating swipe direction
direction = endPos - startPos;
rb.isKinematic = false;
rb.AddForce(direction.x * throwForceInXandY, direction.y * throwForceInXandY,0);
and here a hardcopy from the unity screen:
