*UPDATED* Basic Slender AI in Unity (Unity C# Tutorial)

preview_player
Показать описание
This is an updated tutorial to my tutorial where I show you guys how to make a basic Slender AI in Unity. In the last tutorial, there was an issue with the detection where the player could detect Slender through the walls., but I'm happy to see that I've fixed it and show it in this updated video.

You guys are free to make whatever changes you want to these scripts to suit them for your game or polish them up a bit more.

Be sure to watch the original tutorial if you haven't already since I talk about the rest of the AI there, this video is mainly for the fixed Slender detection:

#Unity #Unity3D #gamedev

*Scripts will be in pinned comment.*

For more Unity tutorials like this or more videos in general - be sure to like, comment, and subscribe for more! 👍

Play Mooshie's Kitchen now:

Wishlist Bodhi 'n' Friends on Steam now:

Follow me on Twitter:

Try out my games:

My Website:

Subscribe to my Second Channel:

Join my Discord:

Facebook Page:
Рекомендации по теме
Комментарии
Автор

Something I wanted to mention is to make sure you mess around with the values on the lookAtSlender script. I find that if the values used for making the screen go static, increasing the audio, and lowering the health are around the same or lower than their recharge rates, there'll be some oddities. So make sure them values are set higher than
the recharge rates if you encounter any issues like that. You guys are free to make whatever changes you want to these scripts to suit them for your game or polish them up a bit more.

Scripts:

Updated lookAtSlender Script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;

public class lookAtSlender : MonoBehaviour
{
public RawImage staticImage;
public Color color;
public float drainRate, rechargeRate, health, healthDamage, healthRechargeRate, maxStaticAmount;
public float audioIncreaseRate, audioDecreaseRate;
public bool looking, canRecharge, usingHealthSlider;
public AudioSource staticSound;
public string deathScene;
public Slider healthSlider;
public raycastSlender detectedScript;

void Start()
{
color.a = 0f;
if(usingHealthSlider == true)
{
healthSlider.maxValue = 100;
}
health = 100f;
}
void OnBecameVisible()
{
looking = true;
}
void OnBecameInvisible()
{
looking = false;
}
void Update()
{
if(usingHealthSlider == true)
{
healthSlider.value = health;
}
if (color.a > maxStaticAmount)
{

}
else if(color.a < maxStaticAmount)
{
staticImage.color = color;
}
if(detectedScript.detected == true)
{
if (looking == true)
{
color.a = color.a + drainRate * Time.deltaTime;
health = health - healthDamage * Time.deltaTime;
staticSound.volume = staticSound.volume + audioIncreaseRate * Time.deltaTime;
}

}
if (looking == false || detectedScript.detected == false)
{
color.a = color.a - rechargeRate * Time.deltaTime;
if (canRecharge == true)
{
health = health + healthRechargeRate * Time.deltaTime;
}
staticSound.volume = staticSound.volume - audioDecreaseRate * Time.deltaTime;
}
if(health < 1)
{

}
}
}

raycastSlender Script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class raycastSlender : MonoBehaviour
{
public GameObject playerObj;
public Transform slenderTransform;
public bool detected;
public Vector3 offset;

void Update()
{
Vector3 direction = playerObj.transform.position - slenderTransform.position;
RaycastHit hit;
if + offset, direction, out hit, Mathf.Infinity))
{
Debug.DrawLine(slenderTransform.position, hit.point, Color.red, Mathf.Infinity);
if (hit.collider.gameObject == playerObj)
{
detected = true;
Debug.Log("hit");
}
else
{
detected = false;
Debug.Log("lol");
}
}
}
}

Omogonix
Автор

Thanks Omogonix !!! Really cool your tutorials and help !

dhidavidhuys
Автор

After being damage the health amount can recharge but when it recharges it can go above 100

officialilynav
Автор

Hello, may i ask how can i made this game multiplayer? I mean, all the players are the seakers and slenderman will allways be the ai, so, is it posible? Just via Lan no need to do it from diferent networks, i know its more dificult and that u need a server just for that

Icenickman
Автор

Very good tutorial, say do you think you could make one on inventory in Unity?

JayV
Автор

hi omogonix i making a game called slenderman warehouse i tested the ai for this and it works

NeighborNerd
Автор

door script download link plss from part 1

berrimasouhail
Автор

Hello, can you please make a tutorial on how to make a stop time ability (but with the player still having the ability to move)? Thank you so much!

kubzcz
Автор

hey can you fix that slender can teleport during looking?

Nothing-xoqo
welcome to shbcf.ru