Tengo este código:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class bullet_codigo : MonoBehaviour
{
public float speed=1f;
// Start is called before the first frame update
void Start()
{
this.GetComponent<Rigidbody2D>().velocity = new Vector3(0,speed,0);
if(transform.position.y>10.5)
{
Destroy(gameObject);
}
}
// Update is called once per frame
void Update()
{
}
}
No importa si coloco el if
en la funcion Start
o Update
igual me funciona, se supone que el método Start
se activa solo una vez inicia el programa y el método Update
es un bucle infinito hasta que termine la ejecución del programa.
¿Por que ejecuta el if
de la misma manera en el Update
y en el Start()
?