- Home /
Question by
SUBSONICuk · Nov 03, 2013 at 06:40 PM ·
javascriptteleport
Random string variable help
I'm making a horror game and to get to the point its like a teleport script, but its a test at first. The thing im trying to do is make a random string variable so it'd choose either " " or "-". for plus or minus. heres the broken string: var flip = Random("","-");
And here's the script i'm trying to add it to: #pragma strict var difficulty = 4; var player : Transform; function Start () {
}
function Update () {
var dist = Vector3.Distance(player.position, transform.position);
var X = player.transform.position.x;
var Y = player.transform.position.y;
var Z = player.transform.position.z;
if(Input.GetKeyDown("l"))
transform.position = Vector3(X + difficulty,Y,Z + difficulty);
}
The normal script works but it moves at exactly x = 0 y = 4 z = 4 but i want it to have a random either 4 or -4. Thanks in advance
Comment