- Home /
AI Script Problem, Horror Game
I'm currently in the process of making a horror game with a story to it. It's not just pointless wet yourself then never touch the mouse again. It's follow the story, enjoy the motivations, then wet yourself a few times. I'm a 3D artist making the map (A replica of a few blocks of a real town located in south weber utah. Very high poly) and thats the problem. I'm missing a very important AI script. I've made my own but really first day trying scripting and im having problems with it.
var target : Transform; //the enemy's target
var moveSpeed = 3; //movespeed
var stopSpeed = 0;
var rotationSpeed = 3; //speed of turning
var myTransform : Transform; //current currents transform data of this enemy
function Awake()
{
myTransform = transform; // cach transform data for easy accessperformance
}
function Start ()
{
target = GameObject.FindWithTag("player").transform; //target the player
}
function update () {
var Speed = moveSpeed;
if (renderer.isVisible)
{
myTransform.Position += myTransform.forward * stopSpeed * Time.deltaTime;
}
if(!renderer.isVisible)
{
myTransform.Position += myTransform.forward * moveSpeed * Time.deltaTime;
}
//rotate to look at the player
myTransform.rotation = Quaternion.Slerp(myTransform.rotation,
Quaternion.LookRotation(target.Position - myTransform.Position), rotationSpeed*Time.deltaTime);
}
//if you are looking at the object...
if (renderer.isVisible)
{
move = false;
}
//if you are NOT looking at the object...
if(!renderer.isVisible)
{
move = true;
}
//if you are not looking at the object...
if(move)
{
//make him look at the target
transform.LookAt(target);
//always follow the target
myTransform.position += myTransform.position.straight * moveSpeed * Time.deltaTime;
}
//if he is 3 units away from something, move right (works if you are not looking at the object)
if (Physics.Raycast (transform.Position.forward) && move)
{
Debug.Log("Something ahead, moving");
transform.Translate(Vector3.right * 3 * Time.deltaTime);
}
I need it to be like a slenderman sort of AI. Meaning, i need my enemy to stalk, teleport, and appear at a selected game object(e.g. behind door in a closet). My script doesn't have all i need and its junk anyways. ill just stick to modeling. I would really appreciate any help anybody can give, and if you come up with a script i;ll put your name in the credits.
So many Slender Questions! I am ready to make a tutorial just to stop them! And so it cannot be said that I wasn't constructive or helpful, everything you want is here :
http://answers.unity3d.com/questions/287355/slender-like-game.html
http://answers.unity3d.com/questions/296068/how-to-make-a-slender-man-follow-character-script.html
http://answers.unity3d.com/questions/319733/how-to-make-enemy-kill-you-if-starring-at-it.html
http://forum.unity3d.com/threads/134862-Slender-$$anonymous$$an-Design-Outline
http://www.parsecproductions.net/slendermangame.txt
http://forum.unity3d.com/threads/141488-Slender-Beta-0.9
http://forum.unity3d.com/threads/138399-Slender-$$anonymous$$an-WIP
It's up to you to find the useful information among that. Read.
Break it down to one simple thing. Work out how to find if one object can "see" another. Once you do that, you can make it do anything you like with that as a trigger. And you can do it both for the player and the 'man' .
http://answers.unity3d.com/questions/323129/if-anyones-looking-for-a-flashlight-script-with-a.html
http://answers.unity3d.com/questions/316189/i-want-to-turn-my-flashlight-on-and-off-while-stil.html
http://www.youtube.com/watch?v=nmvCaqNGEFU&feature=related
http://answers.unity3d.com/questions/15438/trying-to-pick-up-and-see-paper-pop-up-gui-window.html
http://answers.unity3d.com/questions/321749/how-do-you-pick-up-pages-like-in-slender.html
http://cgcookie.com/unity/2011/12/05/introduction-to-character-controllers/
http://unity3d.com/support/resources/assets/terrain-assets
http://unity3d.com/support/resources/unity-extensions/terrain-toolkit
Thanks, I'll take a look at it. And I'm not making another slender game :p I think there is plenty going around about that
Your answer
Follow this Question
Related Questions
ai spot you with flashligt on!!! 1 Answer
Problems with simple AI script 3 Answers
Change AI Follow Players 1 Answer
Timer activates script 1 Answer
How to create a basic follow AI 1 Answer