Slender like game

Hi, I came here because i have a
very basic knowledge of C++. I am making a game like the horror game Slender, I have a character and i want him to randomly teleport around the map until he comes into the vicinity of the player. I also would like to be able to play a sound when he is in the
general area of the player. I know that this is fairly complicated and i am sorry for that but i dont know where else to go to find out such specific scripts.

They are right, you will want to run through some tutorials to get familiar with Unity.

If you like C++ and are comfortable with it I would suggest using C# as your programming language.

I can provide you with a very basic script that you can and will need to add to in order to optimize it for your specific purpose.

C#

using UnityEngine;
using System.Collections;

public class Teleporter : MonoBehaviour
{
    public Transform player;      // the Object the player is controlling
    public Vector3 spawnOrgin;     // this will be the bottom right corner of a square we will use as the spawn area
    public Vector3 maximum;        // max distance in the x, y, and z direction the enemy can spawn
    public float spawnRate;        // how often the enemy will respawn
    public float distanceToPlayer; // how close the enemy has to be to the player to play music

    private bool nearPlayer = false; // use this to stop the teleporting if near the player
    private float nextTeleport = 0.0f; // will keep track of when we to teleport next

    void Start ()
    {
         nextTeleport = spawnRate;
    }

    void Update ()
    {
         if (!nearPlayer)     // only teleport if we are not close to the player
         {
            if (Time.time > nextTeleport)   // only teleport if enough time has passed
            {
              transform.position = new Vector3( Random.Range(spawnOrgin.x, maximum.x), Random.Range(spawnOrgin.y, maximum.y), Random.Range(spawnOrgin.z, maximum.z) );   // teleport
              nextTeleport += spawnRate;    // update the next time to teleport
            }
         }
         if (Vector3.Distance(transform.position, player.position) <= distanceToPlayer)
         {
             if (audio && audio.clip && !audio.isPlaying)     // play the audio if it isn't playing
                  audio.Play();
             nearPlayer = true;
         }
         else
         {
             if (audio)
                 audio.Stop();
             nearPlayer = false;
         }
    }

}

Javascript

var player : Transform;      // the Object the player is controlling
var spawnOrgin : Vector3;     // this will be the bottom right corner of a square we will use as the spawn area
var maximum : Vector3;        // max distance in the x, y, and z direction the enemy can spawn
var spawnRate : float;        // how often the enemy will respawn
var distanceToPlayer : float; // how close the enemy has to be to the player to play music

private var nearPlayer : boolean = false; // use this to stop the teleporting if near the player
private var nextTeleport : float = 0.0f; // will keep track of when we to teleport next

function Start ()
{
    nextTeleport = spawnRate;
}

function Update ()
{
    if (!nearPlayer)     // only teleport if we are not close to the player
    {
        if (Time.time > nextTeleport)   // only teleport if enough time has passed
        {
            transform.position = Vector3( Random.Range(spawnOrgin.x, maximum.x), Random.Range(spawnOrgin.y, maximum.y), Random.Range(spawnOrgin.z, maximum.z) );   // teleport
            nextTeleport += spawnRate;    // update the next time to teleport
        }
    }
    if (Vector3.Distance(transform.position, player.position) <= distanceToPlayer)
    {
         if (audio && audio.clip && !audio.isPlaying)     // play the audio if it isn't playing
              audio.Play();
         nearPlayer = true;
    }
    else
    {
         if (audio)
            audio.Stop();
         nearPlayer = false;
    }
}

The Inspector is your best friend. Attach this script to the enemy GameObject in your scene and edit the exposed variables (the public ones) in the Inspector window. To assign the player variable simply drag the player gameObject from the Hierarchy window into the variable field.

You will also need to attach and AudioSource component to the enemy GameObject and assign a clip to it in the Inspector. Take a look at the unity documentation and tutorials for further details on that.

thank you very much I will try to learn C#, but till then you have helped me a heap.

Slender was created in unity just to let you know. I would start off by writing some scripts where if you collide with the page create a GUI.Label (not sure if its the same in c#.) but yah.Good luck to you.