Here is the code I want to try but can't:
if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved)
{
Vector2 touchDeltaPosition = Input.GetTouch(0).deltaPosition;
rb.AddForce(new Vector3(-touchDeltaPosition.x * Speed *
Time.deltaTime, 0, -touchDeltaPosition.y * Speed * Time.deltaTime));
}
So would this work on a smartphone to push the rigid body in the direction that you swiped to?
↧