Class: Projectile
- Namespace:
Global - Assembly:
Dew.Core.dll - Inheritance / Derived: DewNetworkBehaviour → Actor → AbilityInstance → StandardProjectile
public abstract class Projectile : AbilityInstance, ILogicUpdate, ICleanup, ICustomDestroyRoutineFields
| Name | Declaration | Description |
|---|---|---|
_estimatedVelocity | protected Vector3 _estimatedVelocity | |
canCollideMidFlight | `[BoxGroup("Projectile Settings", true, false, 0)] | |
| [LabelText("Can Collide With Entity Mid-Flight")] | ||
| [ToggleLeft] | ||
| public bool canCollideMidFlight` | ||
collisionRadius | `[Title("Collisions", null, TitleAlignments.Left, true, true)] | |
| [BoxGroup("Projectile Settings", true, false, 0)] | ||
| public float collisionRadius` | ||
collisionTargets | `[ShowIf("canCollideMidFlight", true)] | |
| [BoxGroup("Projectile Settings", true, false, 0)] | ||
| public AbilityTargetValidator collisionTargets` | ||
customEndHeight | `[ShowIf("@mode != Projectile.ProjectileMode.Target && !endsWithSameHeight", true)] | |
| [BoxGroup("Projectile Settings", true, false, 0)] | ||
| public float customEndHeight` | ||
destroyOnComplete | `[FormerlySerializedAs("killOnComplete")] | |
| [BoxGroup("Projectile Settings", true, false, 0)] | ||
| public bool destroyOnComplete` | ||
dissipateOnTerrain | `[BoxGroup("Projectile Settings", true, false, 0)] | |
| [ToggleLeft] | ||
| public bool dissipateOnTerrain` | ||
effectOnComplete | `[BoxGroup("Projectile Settings", true, false, 0)] | |
| [LabelText("Complete")] | ||
| public GameObject effectOnComplete` | ||
effectOnDissipate | `[BoxGroup("Projectile Settings", true, false, 0)] | |
| [LabelText("Dissipate")] | ||
| public GameObject effectOnDissipate` | ||
effectOnEntity | `[BoxGroup("Projectile Settings", true, false, 0)] | |
| [LabelText("Entity")] | ||
| public GameObject effectOnEntity` | ||
effectOnFly | `[Title("Effects", null, TitleAlignments.Left, true, true)] | |
| [BoxGroup("Projectile Settings", true, false, 0)] | ||
| [LabelText("Fly")] | ||
| public GameObject effectOnFly` | ||
endDistance | `[ShowIf("@mode == Projectile.ProjectileMode.Direction", true)] | |
| [BoxGroup("Projectile Settings", true, false, 0)] | ||
| public float endDistance` | ||
endsWithSameHeight | `[ShowIf("@mode != Projectile.ProjectileMode.Target", true)] | |
| [BoxGroup("Projectile Settings", true, false, 0)] | ||
| public bool endsWithSameHeight` | ||
horizontalOffsetOverTrajectory | `[LabelText("Horizontal Offset")] | |
| [BoxGroup("Projectile Settings", true, false, 0)] | ||
| public AnimationCurve horizontalOffsetOverTrajectory` | ||
killOnDissipate | `[BoxGroup("Projectile Settings", true, false, 0)] | |
| public bool killOnDissipate` | ||
mode | `[Title("Flight", null, TitleAlignments.Left, true, true)] | |
| [EnumToggleButtons] | ||
| [BoxGroup("Projectile Settings", true, false, 0)] | ||
| public Projectile.ProjectileMode mode` | ||
onEntity | public SafeAction<Projectile.EntityHit> onEntity | |
rotationType | `[LabelText("Rotation")] | |
| [EnumToggleButtons] | ||
| [BoxGroup("Projectile Settings", true, false, 0)] | ||
| public Projectile.RotationType rotationType` | ||
scaleHorizontalOffsetOnLength | `[LabelText("Scale On Trajectory Length")] | |
| [BoxGroup("Projectile Settings", true, false, 0)] | ||
| public bool scaleHorizontalOffsetOnLength` | ||
scaleVerticalOffsetOnLength | `[LabelText("Scale On Trajectory Length")] | |
| [BoxGroup("Projectile Settings", true, false, 0)] | ||
| public bool scaleVerticalOffsetOnLength` | ||
start | `[EnumToggleButtons] | |
| [BoxGroup("Projectile Settings", true, false, 0)] | ||
| public Projectile.StartPositionType start` | ||
startInFrontDistance | `[LabelText("Front Distance")] | |
| [BoxGroup("Projectile Settings", true, false, 0)] | ||
| public float startInFrontDistance` | ||
verticalOffsetOverTrajectory | `[LabelText("Vertical Offset")] | |
| [BoxGroup("Projectile Settings", true, false, 0)] | ||
| public AnimationCurve verticalOffsetOverTrajectory` |
Properties
| Name | Declaration | Description |
|---|---|---|
isCompleted | public bool isCompleted { get; } | Did this projectile complete its course? |
isFlying | public bool isFlying { get; } | Is this projectile still flying over its course? |
targetEntity | protected Entity targetEntity { get; } | |
targetPosition | protected Vector3 targetPosition { get; set; } | It is recommended to edit this only in OnPrepare. |
Methods
AddEffect(AddEffectTarget, GameObject)
Locally add an effect.Given effect will be instantiated and set/added to this projectile.
public void AddEffect(Projectile.AddEffectTarget target, GameObject eff)Parameters:
| Name | Type | Description |
|---|---|---|
target | Projectile.AddEffectTarget | |
eff | UnityEngine.GameObject |
CalculateOffsetOverTrajectoryInWorldSpace(float, Quaternion)
protected Vector3 CalculateOffsetOverTrajectoryInWorldSpace(float normalizedPosition, Quaternion rotation)Parameters:
| Name | Type | Description |
|---|---|---|
normalizedPosition | float | |
rotation | UnityEngine.Quaternion |
Returns: UnityEngine.Vector3
CheckForCompletion()
protected virtual bool CheckForCompletion()Returns: bool
Dissipate()
Dissipate this projectile.
public void Dissipate()FrameUpdate()
public override void FrameUpdate()GetTargetWorldPosition()
protected virtual Vector3 GetTargetWorldPosition()Returns: UnityEngine.Vector3
LogicUpdate(float)
public override void LogicUpdate(float dt)Parameters:
| Name | Type | Description |
|---|---|---|
dt | float |
OnComplete()
Called on server when this Projectile fully completes its path without being despawned by itself/dissipated.Default behaviour instantiates a neweffectOnCompleteeffect using the position and rotation of this projectile on every clients, and stopseffectOnFlyeffect.It will also kill this projectile ifkillOnCompleteis set.Note: On targeted projectiles, normallyOnEntitywill be fired beforeOnComplete. It might fire differently if for example the projectile is detached or the target became an invalid target.
protected virtual void OnComplete()OnCreate()
protected override void OnCreate()OnDestroyActor()
protected override void OnDestroyActor()OnDisable()
protected override void OnDisable()OnDissipate()
Called on server when this Projectile is dissipated by an outer source. e.g. Projectile Absorbing WallDefault behaviour instantiates a neweffectOnDissipateeffect using the position and rotation of this projectile on every clients
protected virtual void OnDissipate()OnEntity(EntityHit)
Called on server when this Projectile in server detects a collision with an Entity.Default behaviour instantiates a neweffectOnEntityeffect at the hit point with the rotation of this projectile attached to the entity on every clients.
protected virtual void OnEntity(Projectile.EntityHit hit)Parameters:
| Name | Type | Description |
|---|---|---|
hit | Projectile.EntityHit |
OnPrepare()
protected override void OnPrepare()OnStartServer()
public override void OnStartServer()PositionSolver(float)
protected abstract Vector3 PositionSolver(float dt)Parameters:
| Name | Type | Description |
|---|---|---|
dt | float |
Returns: UnityEngine.Vector3
RotationSolver(float)
protected virtual Quaternion RotationSolver(float dt)Parameters:
| Name | Type | Description |
|---|---|---|
dt | float |
Returns: UnityEngine.Quaternion
SetCustomStartPosition(Vector3)
Set custom start position for projectiles with 'Custom' start position mode. Call this in OnPrepare.
public void SetCustomStartPosition(Vector3 pos)Parameters:
| Name | Type | Description |
|---|---|---|
pos | UnityEngine.Vector3 |
StopFlying()
Stop this projectile and itseffectOnFlyeffect. This will also make this projectile instantly stop checking collisions. Note that this does not callOnCompletenorOnDissipate.
protected void StopFlying()