[Unity] Sends bullets from the location where the mouse is clicked.
I would like to write a sample that sends bullets flying from the location where the mouse is clicked on the screen.
First, add a new script to the Main Camera. File name Shoot
The contents of the Shoot script are as follows
Next, prepare an object (Bullet) that will be used as a bullet, add a Rigidbody component, and prefabricate the object.
The prepared Bullet is set to Bullet Pref in the Shoot script.
Below is a sample actually built in WebGL.
The Bullet will fire forward when left-clicked.
– Sample –
There may be a better way, but please refer to it if you like. m