Well, I finally debugged my script of all syntax errors, yay! However, now it’s just not doing what I want it to.
The goal of my script, is, upon the model looking at it at a distance of 3 units, the fire (Represented by a particle system), will go out. The script, and the particle system itself, is attached to the same model.
The script which details the whole ‘making the fire going out’ thing is here:
using UnityEngine;
using System.Collections;
public class FireManager : MonoBehaviour {
bool FireIsOn = true;
float fireTimer = 0.0f;
public float fireStopTime = 5.0f;
GameObject currentFire;
// Use this for initialization
void Start () {
fireTimer = 0.0f;
}
void FireCheck (){
if(!FireIsOn){
gameObject.GetComponent<ParticleSystem>().enableEmission = false;
}
}
// Update is called once per frame
void Update () {
if (FireIsOn){
fireTimer += Time.deltaTime;
}
if (fireTimer > fireStopTime){
gameObject.GetComponent<ParticleSystem>().enableEmission = true;
fireTimer = 0.0f;
}
}
}
The other part is in a main script detailing all the collisions the player can make, here’s the fire part of it:
RaycastHit hitFire;
if(Physics.Raycast(transform.position, transform.forward, out hitFire, 3)){
if(hitFire.collider.gameObject.tag == "playerFire"){
currentFire = hitFire.collider.gameObject;
currentFire.SendMessage("FireCheck");
}
}
So, what have I done in order to result in my script not doing what I intended it to do?