Cosmic Strike
 
Cargando...
Buscando...
Nada coincide
TripleShot.cs
Ir a la documentación de este archivo.
1
9
10using UnityEngine;
11
17{
18 // ========== PARÁMETROS CONFIGURABLES ==========
19
24 public GameObject bulletPrefab;
25
30 public Transform firePoint;
31
35 public float speed;
36
40 public float spreadAngle;
41
42 // ========== INICIALIZACIÓN ==========
43
48 void Awake()
49 {
50 if (firePoint == null)
51 {
52 var playerGO = GameObject.Find("Player");
53 if (playerGO != null)
54 {
55 // Dentro del Player, buscamos el hijo FirePointCenter
56 var fp = playerGO.transform.Find("FirePointCenter");
57 if (fp != null)
58 {
59 firePoint = fp;
60 }
61 else
62 {
63 Debug.LogError("TripleShot: no existe un hijo 'FirePointCenter' bajo 'Player'.");
64 }
65 }
66 else
67 {
68 Debug.LogError("TripleShot: no se encontró ningún GameObject llamado 'Player' en la escena.");
69 }
70 }
71 }
72
73 // ========== DISPARO ==========
74
79 public override void Shoot()
80 {
81 for (int i = -1; i <= 1; i++)
82 {
83 var rot = firePoint.rotation * Quaternion.Euler(0, 0, i * spreadAngle);
84 GameObject b = Instantiate(bulletPrefab, firePoint.position, rot);
85 b.GetComponent<Rigidbody2D>().linearVelocity = rot * Vector3.up * speed;
86 }
87 }
88}
Clase base abstracta que define la interfaz de comportamiento para proyectiles. Cada clase hija debe ...
Componente de disparo que lanza tres proyectiles en abanico desde un único punto de disparo central....
Definition TripleShot.cs:17
override void Shoot()
Lanza tres proyectiles simultáneos con ángulos de dispersión calculados. Los ángulos se definen como ...
Definition TripleShot.cs:79
float speed
Velocidad de desplazamiento de los proyectiles en unidades por segundo.
Definition TripleShot.cs:35
float spreadAngle
Ángulo de separación en grados entre los proyectiles laterales y el central.
Definition TripleShot.cs:40
void Awake()
En caso de no tener firePoint asignado, se intenta encontrar automáticamente un hijo llamado "FirePoi...
Definition TripleShot.cs:48
Transform firePoint
Punto central desde el cual se lanzan los tres disparos. Si no se asigna, se buscará automáticamente ...
Definition TripleShot.cs:30
GameObject bulletPrefab
Prefab del proyectil que será instanciado en cada disparo. Debe tener un Rigidbody2D para aplicar la ...
Definition TripleShot.cs:24