Skip to content

Kick a ball where it was clicked

Updated

A click on the ball casts a physics ray and applies an impulse along it at the point hit, so an off-centre click also sets the ball spinning.

Click the ball to kick it away from you; click its edge to make it spin. Drag to orbit the camera, scroll to zoom.

Kick a ball where it was clicked

The script is explained step by step in Kick a ball where it was clicked.

Download the project file below, then import it in XR Hub with Projects › New › Import, as described in Projects and templates. It opens in XR Creator with the same scene you see running above, each script already attached to its Behavior entity. From there you can edit the scripts, adjust components and their props, preview your changes, and deploy the result as a world of your own.

KickBall.xrproj