Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(1 edit)

Ok 

using System;
using UnityEngine;
using UnityEngine.AI;
using System.Collections;
// Token: 0x020000CE RID: 206
public class FoggyScript : MonoBehaviour
{
    // Token: 0x060009B7 RID: 2487 RVA: 0x000254D9 File Offset: 0x000238D9
    private void Start()
    {
        this.agent = base.GetComponent<NavMeshAgent>(); // Define the AI Agent
    }
    // Token: 0x060009B8 RID: 2488 RVA: 0x000254ED File Offset: 0x000238ED
    private void Update()
    {
        if (this.coolDown > 0f)
        {
            this.coolDown -= 1f * Time.deltaTime;
        }
    }
    // Token: 0x060009B9 RID: 2489 RVA: 0x00025518 File Offset: 0x00023918
    private void FixedUpdate()
    {
         if (this.agent.velocity.magnitude <= 1f & this.coolDown <= 0f)
         {
             this.Wander();
         }
    }
    // Token: 0x060009BA RID: 2490 RVA: 0x000255CD File Offset: 0x000239CD
    private void Wander()
    {
        this.wanderer.GetNewTarget();
        this.agent.SetDestination(this.wanderTarget.position); //Set its destination to position of the wanderTarget
        this.coolDown = 1f;
    }
    private void OnTriggerEnter(Collider other)
    {
        if (other.name == "Player" & !this.collided)
        {
            this.collided = true;
            this.StartCoroutine(this.FogTime());
        }
    }
    private IEnumerator FogTime()
    {
        RenderSettings.fogDensity += 0.1f;
        yield return new WaitForSeconds(30f);
        RenderSettings.fogDensity -= 0.1f;
        this.collided = false;
    }
    public bool collided;
    // Token: 0x040006B4 RID: 1716
    public Transform wanderTarget;
    // Token: 0x040006B5 RID: 1717
    public AILocationSelectorScript wanderer;
    // Token: 0x040006B6 RID: 1718
    public float coolDown;
    // Token: 0x040006B7 RID: 1719
    public NavMeshAgent agent;
}

What to put in Agent and WanderTarget?

WanderTarget: AI_LocationSelector.

How about agent?

Agent was set to public by accident, so leave it blank.

He is not making school fog. What to do?

Are there any errors relating to your script? If so, tell me what it says.

There is not.

(1 edit)

Hmm, in OnTriggerEnter, change "other.name" to "other.tag". Does it work now?

No, that was not it.