hi guys its david here,and today I have a problem with my script that I’ve been working on for the last 5 days that has only one error.take a look at my script an figure out whats the problem please someone.
using UnityEngine;
using System.Collections;
using System;
public class ClickObjectTeleport : MonoBehaviour
{
public int spawnVariance = 0;
private static System.Random random = new System.Random();
public bool showTeleportParticleEffect = true;
public GameObject teleportParticleGenerator;
public Transform teleportDestination;
void OnMouseOver()
{
if (Input.GetMouseButtonDown(0))
{
DoTeleport(teleportDestination);
}
}
void DoTeleport(Transform target)
{
string localPlayerName = LocalPlayer;
GameObject localPlayer = GameObject.Find(localPlayerName);
float offsetX = random.Next(spawnVariance);
float offsetZ = random.Next(spawnVariance);
Vector3 newPosition = target.position;
newPosition.x = target.position.x + offsetX;
newPosition.z = target.position.z + offsetZ;
localPlayer.transform.position = newPosition;
localPlayer.transform.rotation = target.rotation;
if (showTeleportParticleEffect)
{
if (teleportParticleGenerator != null)
{
Instantiate(teleportParticleGenerator, newPosition, target.rotation);
}
}
}
}
the error that I’ve had for 5 days is this:
Assets/ClickObjectTeleport.cs(24,42): error CS0103: The name `LocalPlayer’ does not exist in the current context
can anybody help me on this please?