[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



![[Unity] Removing grass grown on Terrain from scripts](https://kuroko-labo.com/wp/wp-content/uploads/2025/05/grass2.png)
![[Unity] Executing a method at an arbitrary time with Photon’s PUN2](https://kuroko-labo.com/wp/wp-content/themes/kuroko3/images/noimage.png)
![[Unity]I made a field with Gaia Pro 2023.](https://kuroko-labo.com/wp/wp-content/uploads/2025/01/image06.png)
![[Unity]I bought an OLD TV Filter.](https://kuroko-labo.com/wp/wp-content/uploads/2019/11/image05.png)
![[Unity]Try to create a circle gauge that advances when the mouse is clicked.](https://kuroko-labo.com/wp/wp-content/uploads/2019/07/circle.fw_.png)
![[Unity]Use localPosition to create a conveyor belt-like](https://kuroko-labo.com/wp/wp-content/uploads/2019/06/image01-1.png)