plantilla base para movimiento básico
This commit is contained in:
Robii Aragon
2026-02-05 05:07:55 -08:00
parent 195b696771
commit 779f2c8b20
14443 changed files with 23840465 additions and 452 deletions

View File

@@ -0,0 +1,77 @@
using UnityEngine;
using System.Collections;
public class laser : MonoBehaviour
{
[Header ("Laser Settings")]
[Space]
public float scrollSpeed = 0.09f;
public float pulseSpeed = 0.28f;
public float noiseSize = 0.19f;
public float maxWidth = 0.1f;
public float minWidth = 0.2f;
public bool animateLaserEnabled = true;
[Space]
[Header ("Components")]
[Space]
public LineRenderer lRenderer;
public Renderer mainRenderer;
[HideInInspector] public float aniDir;
[HideInInspector] public float laserDistance;
float aniFactor;
void Awake ()
{
if (lRenderer == null) {
lRenderer = GetComponent<LineRenderer> ();
}
if (mainRenderer == null) {
mainRenderer = GetComponent<Renderer> ();
}
}
public void animateLaser ()
{
if (animateLaserEnabled) {
mainRenderer.material.mainTextureOffset += new Vector2 (Time.deltaTime * aniDir * scrollSpeed, 0);
aniFactor = Mathf.PingPong (Time.time * pulseSpeed, 1);
aniFactor = Mathf.Max (minWidth, aniFactor) * maxWidth;
lRenderer.startWidth = aniFactor;
lRenderer.endWidth = aniFactor;
mainRenderer.material.mainTextureScale = new Vector2 (0.1f * (laserDistance), mainRenderer.material.mainTextureScale.y);
}
}
public IEnumerator laserAnimation ()
{
//just a configuration to animate the laser beam
aniDir = aniDir * 0.9f + Random.Range (0.5f, 1.5f) * 0.1f;
yield return null;
minWidth = minWidth * 0.8f + Random.Range (0.1f, 1) * 0.2f;
WaitForSeconds delay = new WaitForSeconds (1 + Random.value * 2 - 1);
yield return delay;
}
public virtual void disableLaser ()
{
enabled = false;
if (lRenderer != null) {
lRenderer.enabled = false;
}
}
}