Game Development Reference
In-Depth Information
Next, add the proper switch / case check for the firingWeapon state to onStateCycle ,
onStateChange , checkForValidStatePair , and checkIfAbortOnStateCondition .
Also, add the new state to onStateCycle in the script CameraController . We won't
be using this, but it is always best to make sure all of your states in all scripts are the
same, just in case you find you want to use it in the future. It's OK to leave all of the
cases blank for now.
Let's add a quick transform node that we can use as the spawn point for the bullets.
Create a GameObject, name it BulletSpawnPoint , and make it a child of the Player
object. Assign its position X: 0.21 , Y: 1.08 . It should look a little something like
the following screenshot:
At the beginning of PlayerStateListener , add the following code:
public Transform bulletSpawnTransform;
Then, apply the BulletSpawnPoint GameObject to that new property in the
Inspector panel.
In the onStateChange method's case, check in PlayerStateListener and add
the following code to the new firingWeapon state:
// Make the bullet object
GameObject newBullet =
(GameObject)Instantiate(bulletPrefab);
// Set up the bullet's starting position
 
Search WWH ::




Custom Search