Expanding Project
Adding new weapon
Create a new prefab or duplicate an existing weapon.
Make sure that there is at least one
WeaponAction
component and appropriate weapon components on the prefab.WeaponAction
and weapon components can be all on oneGameObject
(seeSniper
prefab) or in case of multiple weapon actions it needs to be placed in hierarchy (seeRifle
prefab).Set the
WeaponSlot
in theWeapon
component to specify which place it should occupy in the player weapons array.Optionally assign weapon name and icon in the
Weapon
component.Assign weapon to
Initial Weapons
field in theWeapons
component on thePlayerAgent
prefab.
![weapons inspector](/docs/img/fusion/v2/samples/projectiles/fusion-projectiles-weapons-inspector.png)
Adding new projectile
Create a new prefab or duplicate existing projectile. Make sure there is a component that inherits from
Projectile
.Assign projectile prefab to weapon prefab in
WeaponBarrel
component.
![weaponbarrel inspector](/docs/img/fusion/v2/samples/projectiles/fusion-projectiles-weapon-barrel.png)
- Assign projectile prefab in the
HitscanProjectileBuffer
orKinematicProjectileBuffer
on the controlling object (e.g. thePlayerAgent
prefab) to make sure it will spawn the projectile when fired.
Switch to third person
Fusion Projectiles is built as an FPS game but most of the functionality applies for TPS games as well. When firing in TPS games, first a ray needs to be cast from the camera to find the point at which the player is trying to shoot. The actual projectile cast will then be from a position on character (fixed position near character shoulder usually works well) to the point obtained from the camera cast. There are usually some tricks (like ignoring some collisions with second cast) involved so players won’t be hitting unwanted objects too much (corners issue). Check out Fusion BR for a TPS handling example.
Back to top