- Home /
Question by
shemeer9947 · Jan 08, 2018 at 03:35 PM ·
playerplayer movementmovinggameobject
i want to move a rigidbody using touch button
// Update is called once per frame public void Update () { if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began) { ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position); if (Physics.Raycast(ray, out hit, Mathf.Infinity))
if (hit.rigidbody != null)
hit.rigidbody.AddForce(leftforce * Time.deltaTime, 0, 0, ForceMode.VelocityChange);
}
}
Comment