TargetInfo - jimdroberts/FishMMO GitHub Wiki
TargetInfo is a struct for FishMMO that contains information about a target and the hit position. It is used to encapsulate targeting results, including the target's transform and the position where the target was hit, for use in targeting logic and events.
-
public Transform Target
The transform of the target.
-
public Vector3 HitPosition
The position where the target was hit.
-
public TargetInfo(Transform target, Vector3 hitPosition)
Initializes a new instance of the TargetInfo struct. Parameters: - Transform target: The target transform. - Vector3 hitPosition: The hit position. No return value (constructor). No exceptions are thrown.
- Create a new TargetInfo instance with a target transform and hit position.
- Use TargetInfo to pass targeting results between systems or trigger events.
// Example 1: Creating a TargetInfo instance
Transform targetTransform = ...;
Vector3 hitPos = ...;
TargetInfo info = new TargetInfo(targetTransform, hitPos);
// Example 2: Using TargetInfo in an event
myTargetController.OnChangeTarget += (target) => {
TargetInfo info = new TargetInfo(target, hitPos);
// Handle target change
};
- Always provide both the target transform and hit position when creating a TargetInfo instance.
- Use TargetInfo to encapsulate targeting data for clarity and maintainability.
- Document the intended use of TargetInfo in your targeting systems.