Can you make a script for a character called Foggy Copter, and he has multiple angles like 1st prize, and he wanders around and if he touches you, it becomes foggy for 30 seconds. Can you code that please?
Viewing post in Baldi's Basics Tutorial: How to make a custom character comments
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;
}