A class in Root.Township, the global namespace.
Launches a pickup (an arrow or any item) from a bow or similar launcher and syncs the shot. Both sides: the shooting client simulates and sends it, the server relays it to the chunk.
Constructors
| Member | What it is |
|---|
Shooter() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
8 private and internal fields
| Member | What it is |
|---|
private float defaultDeviation | Maximum random angle in degrees added to non-arrow shots fired locally. |
private static Logger logger | Logger for this class. |
private float maxExtra | Extra velocity factor for arrows, scaled by the string tightness. |
private float maxVelocity | Launch speed at full strength, before weight and material adjustments. |
private PhysicalMaterialPart physicalMaterial | Optional material of the bow string; gives tightness, minimum projectile weight and the velocity multiplier for light items. |
private Pickup pickup | The launcher itself; only used to copy its last interactor onto the launched item. |
private RTPC shootStrengthRTPC | Wwise RTPC set from the shot strength for the shoot sound. |
private MethodSyncStruct<ShootArguments> syncShoot | Sync message that carries a shot (ShootArguments). |
Events
| Member | What it is |
|---|
event Action<Shooter, Pickup, Vector3> OnShoot | Raised after a shot with the shooter, the item and its launch velocity. |
event Action<Shooter, Pickup> PreShoot | Raised before a shot, with the shooter and the item about to be launched. |
Methods
| Member | What it is |
|---|
override void Initialize() | Creates the sync used to send shots. |
void Shoot(Pickup pickup, float strength, bool isFromNetwork = false, Vector3 direction = null) | Undocks the item and launches it with the given strength (0 to 1), playing the sound and sending the shot unless it came from the network. |
2 private and internal methods
| Member | What it is |
|---|
private Vector3 DefaultShoot(Vector3 direction, Pickup pickup, float strength, bool isApplyingDeviation) | Launches a non-arrow item: optionally adds random deviation to its aim, then sets its velocity directly and clears spin. |
private void SyncShoot(IPlayer player, Stream stream, ShootArguments args) | Network handler: on receive, moves the item to the sent pose and shoots it; the server then relays the shot to other players. |
Used in
Members of other types that take, return or hold a Shooter: