private Vector2 maxHeadLocation; // Maximum location of the head. /// <summary> /// Initializes the laser. /// </summary> /// <param name="origin">Origin of the local position of the laser in world space</param> /// <param name="originCharacter">Character who fired the laser</param> /// <param name="followOriginCharacter">If true, changes the origin of the laser to origin character's position</param> /// <param name="initialLocalHeadLocation">Start position of the laser in local space</param> /// <param name="timeScale">Time scale to use</param> /// <param name="headVelocity">Velocity of the head</param> /// <param name="maxLaserLength">Maximum length of the laser</param> public void Initialize(Vector2 origin, UDEBaseCharacter originCharacter, bool followOriginCharacter, Vector2 initialLocalHeadLocation, UDETime.TimeScale timeScale, Vector2 headVelocity, float maxLaserLength) { if (initialized) { Debug.LogWarning("You tried to initialize laser that already initialized. Initialization is ignored."); return; } Initialize(origin, originCharacter, followOriginCharacter, initialLocalHeadLocation, timeScale); points.Add(initialLocalHeadLocation); laser.positionCount = 2; laser.SetPosition(1, points[1]); laserCollider.points = points.ToArray(); this.headVelocity = headVelocity; this.maxLaserLength = maxLaserLength; maxHeadLocation = initialLocalHeadLocation + headVelocity * maxLaserLength / headVelocity.magnitude; }