Advertisemen
Check out our YouTube Channel - Aarlangdi dotKom for short films
Hello again guys, how are you today? you said "Goooood". Ok then let's go tutorial.
Today, I will show you guys, creating ball in the position mouse click position in unity3d in a very simple way.

Second step, create sphere from GameObject > Create Other > Sphere and name it ball. now attach rigid body in the ball, we just created. if you don't know how to attach rigid body - select ball object then got to Component > Physics > Rigidbody.
Third step, create prefab from project panel, Create > Prefab and name it ball or whatever you want so you can remember what it is. now drag ball object from Hierarchy into the ball prefab then remove the ball object from the Hierarchy.

span style="color: #351c75;">
Fourth Step, Same like you create Sphere and plane create one Cube and name Spawner and scale it as wider as you want. Now place it where you like to click and produce a ball.
Fifth step, create two javascripts and name like spawner.js and ball.js. Then attach spawner.js to Spawner and ball.js to ball prefab. Now open them up in your favourite script editor and type the following in spawner.js ---
And following in ball.js --- transform.position.y <= -6 varies on the screen size of the game and where do you want destroy balls, in short, boundary for the ball.
Now hit play and click on the spawner it produces a ball on the mouse position. If you want to turn off the visibility of the spawner, just uncheck Mesh Renderer in the Inspector. It still works in a same way like before.

If you guys, didn't understand anything above, just ask me in the comment section. Happy to help you......
Enjoy.
Fourth Step, Same like you create Sphere and plane create one Cube and name Spawner and scale it as wider as you want. Now place it where you like to click and produce a ball.
Fifth step, create two javascripts and name like spawner.js and ball.js. Then attach spawner.js to Spawner and ball.js to ball prefab. Now open them up in your favourite script editor and type the following in spawner.js ---
And following in ball.js --- transform.position.y <= -6 varies on the screen size of the game and where do you want destroy balls, in short, boundary for the ball.
Now hit play and click on the spawner it produces a ball on the mouse position. If you want to turn off the visibility of the spawner, just uncheck Mesh Renderer in the Inspector. It still works in a same way like before.

If you guys, didn't understand anything above, just ask me in the comment section. Happy to help you......
Enjoy.
Advertisemen
Tidak ada komentar:
Posting Komentar