Hey guys,
I have got a problem at my reload function.
I am trying to start a timer after the button “r” is pressed. This timer should be 5 seconds long.
I don’t get the problem.
Here is my script.
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class shoot : MonoBehaviour
{
public float offset;
public bool full = true;
public int ammo = 30;
public GameObject projectille;
public Transform shotPoint;
private float timeBtwShots;
public float startTimeBtwShots;
void Update()
{
if (full == true)
{
if (Input.GetMouseButtonDown(0))
{
Instantiate(projectille, shotPoint.position, transform.rotation);
timeBtwShots = startTimeBtwShots;
ammo–;
}
}
if (ammo == 0)
{
full = false;
}
if (Input.GetButtonDown(“reload”))
{
StartCoroutine(StartTimer(50));
}
}
IEnumerator StartTimer(float timeLeft) //This StartTimer is the problem
{
Reload();
}
void Reload()
{
ammo = 30;
}
}