#Using a variabale on multiple scripts

1 messages · Page 1 of 1 (latest)

crystal flame
#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class EnemyAge : MonoBehaviour
{
public float EfreshAge;
public GameObject epaint;
public GameObject Circle;
public GameObject Player;
public float freshAge;
public PlayerAge FreshAge;

private bool isOnEPaint;
private bool isOnCircle;

private void FixedUpdate()
{


    if (isOnEPaint == false)
    {


        EfreshAge += Time.deltaTime;
    }
    else
    {
        EfreshAge = 0f;
        Debug.Log("EFRESH");
    }
    isOnEPaint = false;

    if (isOnCircle == true)
    {
        Debug.Log("OOB");
        if (EfreshAge > freshAge)
        {

            Debug.Log("ENOTFRESH");
            Instantiate(epaint, transform.position, transform.rotation);
            Destroy(gameObject, 0);

        }
    }

}

public void OnTriggerStay2D(Collider2D collision)
{
    isOnEPaint = collision.gameObject.name == ("Epaint");
    isOnEPaint = collision.gameObject.name == ("Epaint (clone)");
    isOnCircle = collision.gameObject.name == ("Player");
}

}

#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerAge : MonoBehaviour
{
public float freshAge;
public GameObject paint;
public GameObject Circle;
public GameObject Player;
public float efreshAge;
public EnemyAge eFreshAge;

private bool isOnPaint;
private bool isOnCircle;

private void FixedUpdate()
{


    if (isOnPaint == false)
    {
        

        freshAge += Time.deltaTime;
    }
    else { 
        freshAge = 0f;
        Debug.Log("FRESH");
         }
    isOnPaint = false;

    if (isOnCircle == true)
    {
        Debug.Log("BOO");
        if (freshAge > efreshAge)
        {

            Debug.Log("NOTFRESH");
            Instantiate(paint, transform.position, transform.rotation);
        Destroy(gameObject, 0);

        }
    }
    
}

public void OnTriggerStay2D(Collider2D collision)
{
    isOnPaint = collision.gameObject.name == ("paint");
    isOnPaint = collision.gameObject.name == ("paint (clone)");
    isOnCircle = collision.gameObject.name == ("Circle");
}

}