Created
April 2, 2022 18:04
-
-
Save 314pies/250b42787437b6b9a892283ca34b1ed8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ray = cam.ScreenPointToRay(TouchScreenWrap.touches[0].position); | |
RaycastHit hit; | |
if (Physics.Raycast(ray, out hit)) { | |
if (hit.transform.GetComponent<Rigidbody>() != null) | |
{ | |
Vector3 offSet = hit.transform.position - cam.transform.position; | |
hit.transform.GetComponent<Rigidbody>().AddForce(offSet.normalized * Force, ForceMode.VelocityChange); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment