Hi all, ive been trying to get this code to work more smoothly.
I have an object that has a force applied to get it to move upwards, and the longer you hold you press the higher it goes and then dropback down when you let go.
It seems to work to a degree but is very jumpy and not smooth at all, any suggestions on where im going worng please?
if (Input.touchCount >= 1)
{
touch = Input.touches [0];
if (touch.phase != TouchPhase.Ended && touch.phase != TouchPhase.Canceled)
{
rigidbody2D.velocity = Vector2.zero;
rigidbody2D.AddForce(jumpForce);
}
else if (touch.phase == TouchPhase.Ended)
{
rigidbody2D.velocity = Vector2.zero;
rigidbody2D.AddForce(Vector3.up * 0);
}
}