INTERACTIVITY: Shooting and Asteroids
To start this session we wrote the script to move the bullet
after a changing the value in the inspector, the bullet moves across the screen
after getting the bullet ready we created a PreFab and moved our bolt in to that.
Now to get the bolt to spawn we created a point for the script to reference
We then opened up the PlayerController script and added the following:
After adding some more code modifications, especially trying to get both guns to shoot this is what i ended up with
Now, in order to destroy the bullets when they exit the screen, we created a boundary
This added a random rotation to each instance of the asteroid.
after a changing the value in the inspector, the bullet moves across the screen
after getting the bullet ready we created a PreFab and moved our bolt in to that.
Now to get the bolt to spawn we created a point for the script to reference
We then opened up the PlayerController script and added the following:
The next step was to link the objects to the script using the inspector
By adding a small function in to the script and linking it back to the variables, we get our bullets being spawned... maybe a bit too much.
Also to fix the physics colliding with eachother, "Is Trigger" must be checked in the Rigid Body component of the prefab.
To make the bullets only fire when the mouse button (or fire button) is pressed we modified the code:
After adding some more code modifications, especially trying to get both guns to shoot this is what i ended up with
Now, in order to destroy the bullets when they exit the screen, we created a boundary
The next step was to add the asteroid in. After i imported the model i made in the 3D workshop i added the Rididbody and Capsule Collider components, and added a new script to the container.
This is the script that was written:This added a random rotation to each instance of the asteroid.
Dat Tho... |
0 comments: