Skip to main content

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

Can you make a script for me? My character will be called Tattle Time, and if he sees you breaking any rules, he will tell principle and then the principle will be chasing you. Can you code that?

using System;
using UnityEngine;
using UnityEngine.AI;
// Token: 0x02000024 RID: 36
public class CharForOtherMod : MonoBehaviour
{
    // Token: 0x0600007E RID: 126 RVA: 0x00004355 File Offset: 0x00002755
    private void Start()
    {
        this.agent = base.GetComponent<NavMeshAgent>();
        this.aq = base.GetComponent<AudioSource>();
    }
    private void Update()
    {
        if (this.cooldown > 0)
        {
            this.cooldown -= 1f * Time.deltaTime;
        }
        if (this.tattlecooldown > 0)
        {
            this.tattlecooldown -= 1f * Time.deltaTime;
        }
    }
    private void FixedUpdate()
    {
        if (this.agent.velocity.magnitude < 1 & this.cooldown <= 0)
        {
            this.Wander();
        }
        if (this.ps.guilt > 0)
        {
            Vector3 direction = this.ps.transform.position - base.transform.position;
            RaycastHit raycastHit;
            if (Physics.Raycast(base.transform.position, direction, out raycastHit, float.PositiveInfinity, 769, QueryTriggerInteraction.Ignore) && (raycastHit.transform.tag == "Player"))
            {
                if (this.tattlecooldown <= 0)
                {
                    this.tattlecooldown = 20;
                    this.aq.PlayOneShot(this.tellonprincipal);
                }
            }
        }
    }
    private void Wander()
    {
        this.ail.GetNewTarget();
        this.agent.SetDestination(this.dest.position);
    }
    private float cooldown;
    private float tattlecooldown;
    public PlayerScript ps;
    private AudioSource aq;
    // Token: 0x0400009C RID: 156
    private NavMeshAgent agent;
    public AILocationSelectorScript ail;
    public Transform dest;
    public Transform[] classroomLocations;
    public Transform[] exitLocations;
    public int locationID;
    public AudioClip tellonprincipal;
}

There you go.

What to put in dest?

AI_LocationSelector