/// --------------------------------------------- /// Ultimate Character Controller /// Copyright (c) Opsive. All Rights Reserved. /// https://www.opsive.com /// --------------------------------------------- namespace Opsive.UltimateCharacterController.Objects.ItemAssist { using Opsive.Shared.Game; using UnityEngine; /// /// The tracer will show a Line Renderer from the hitscan fire point to the hit point. /// public class Tracer : MonoBehaviour { [Tooltip("The amount of time that the tracer is visible for")] [SerializeField] protected float m_VisibleTime = 0.05f; // Component references private Transform m_Transform; private LineRenderer m_LineRenderer; /// /// Initialize the default values. /// private void Awake() { m_Transform = transform; m_LineRenderer = GetComponent(); } /// /// Sets the hit point that the tracer should move to. /// /// The hit point position. public virtual void Initialize(Vector3 hitPoint) { m_LineRenderer.SetPosition(0, m_Transform.position); m_LineRenderer.SetPosition(1, hitPoint); Scheduler.Schedule(m_VisibleTime, DestroyObject); } /// /// Places the object back in the ObjectPool. /// private void DestroyObject() { ObjectPool.Destroy(gameObject); } } }