I cant figure out how to make the prefab instantiate facing the player, then fire.
int randomO;
float randomY;
float randomX;
public GameObject projectilePrefab;
public Transform spawner;
public Transform player;
public float WaterSpeed;
private float time;
public float maxtime;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
randomO = Random.Range(1, 5);
switch(randomO)
{
case 1:
randomY = 62.9f;
randomX = Random.Range(-83.9f, 83.1f);
break;
case 2:
randomY = -66.8f;
randomX = Random.Range(-83.9f, 83.1f);
break;
case 3:
randomX = -107.9f;
randomY = Random.Range(48.7f, -58.7f);
break;
case 4:
randomX = 100.6f;
randomY = Random.Range(48.7f, -58.7f);
break;
}
transform.position = new Vector2(randomX, randomY);
if (time <= 0.0f)
{
//Heres where i want to instantiate the object.
time = maxtime;
}
}
private void FixedUpdate()
{
if (time >= 0.0f)
{
time -= Time.deltaTime;
}
}