예제 #1
0
        public void Activate(Transform src, Transform tgt, PowerBeam.BeamSettings settings, Color col)
        {
            // make the particles a child of this
            if (settings.beamParticles != null && beamParticles == null)
            {
                beamParticles = Instantiate(settings.beamParticles);
                beamParticles.Init(src);
            }

            texLength = settings.beamLength;

            gameObject.SetActive(true);
            if (lineRenderer == null)
            {
                lineRenderer = GetComponent <LineRenderer>();
            }
            lineRenderer.enabled = (settings.beamMaterial != null);
            timer   = settings.beamDuration;
            source  = src;
            target  = tgt.gameObject;
            uvSpeed = settings.beamUVSpeed;

            if (settings.beamMaterial != null)
            {
                lineRenderer.material = settings.beamMaterial;

                lineRenderer.startColor = lineRenderer.endColor = col;
                lineRenderer.startWidth = lineRenderer.endWidth = settings.beamWidth;

                // set UV tiling to match distance
                float distance = Vector3.Distance(src.position, tgt.position);
                lineRenderer.material.SetTextureScale("_MainTex", new Vector2(2 * distance / texLength, 1));
            }
        }
예제 #2
0
        protected void AddBeamBetween(Character source, Character dest, Character.BodyPart sourceBodyPart, PowerBeam.BeamSettings settings)
        {
            GameObject beamObj = RPGSettings.instance.beamPool.GetObject();

            if (beamObj)
            {
                BeamRenderer beam = beamObj.GetComponent <BeamRenderer>();
                beam.Activate(source.GetBodyPart(sourceBodyPart), dest.GetBodyPart(targetBodyPart), settings, tint.GetColor());
            }
            else
            {
                Debug.Log("Running out of beams! Increase the pool size in RPGSettings");
            }
        }