Hi,
So I’m a beginner in CSharp, and I have to do a game for school. I wanted one of my projectiles to stun the enemy. So I’ve managed to do that, the stunning part actually works, but there is a problem I can’t seem to solve by myself : I want the enemy to be temporarily stunned only. A friend of mine tried to help, but, I don’t know why, it doesn’t work : the object receiving the projectile is stunned and doesn’t regain his movements. The problem is, I’m unable to continue this script, since I don’t understand what my friend tried to do regarding the part of the script written to make it temporary.
using UnityEngine;
using System.Collections;
public class TentativeStun : MonoBehaviour {
public Behaviour move;
public GameObject missile;
public float tempsStun = 1f;
public float tempSecondes = 1f;
public bool touche = false;
public float duréeStun = 0f;
// Use this for initialization
void Start ()
{
duréeStun = tempsStun;
}
// Update is called once per frame
void OnTriggerEnter (Collider other)
{
if (other.gameObject.tag == "stun")
{
move.enabled=false;
touche = true;
Debug.Log ("Il y a eu collision");
}
}
void Update ()
{
if (touche == true)
{
if (duréeStun)
Debug.Log ("On est dans le if touche");
touche = false;
returnattente();
Debug.Log ("Le move est retabli");
move.enabled = true;
tempsStun = duréeStun;
tempSecondes = 0;
}
}
//Here is what my friend did, so I don't understand anything...
IEnumerator attente ()
{
yield return new WaitForSeconds (3);
}
void returnattente ()
{
yield return attente;
}
}
Sorry for my variables’ names are in French, I can rename them in necessary.
Thanks.