- Home /
InputPositionWithLocalOffset Issue o.0
Ok so i use the script below. When the timescale doesn't exist in my script i get no errors and everything is fine. However, when it exists, i get that weird error and when i respawn i cannot move at all with WASD :S The error says something about NaN...
var showGUI : boolean = false;
var original : Vector3;
var player : GameObject;
var theCamera : GameObject;
var theCameraChild : GameObject;
function Start(){
player = GameObject.Find("Player");
original = player.transform.position;
}
function OnTriggerEnter(other:Collider){
if(other.gameObject.name == "Player"){
var otherScript = player.GetComponent(FallDamage);
otherScript.hearts -= 1;
showGUI = true;
theCamera.GetComponent("MouseLook").enabled = false;
theCameraChild.GetComponent("MouseLook").enabled = false;
Time.timeScale = 0.0;
}
}
function OnGUI(){
if(showGUI){
if(GUI.Button(new Rect(20,70,100,50), "Respawn")){
player.transform.position = original;
showGUI = false;
theCamera.GetComponent("MouseLook").enabled = true;
theCameraChild.GetComponent("MouseLook").enabled = true;
Time.timeScale = 1.0;
}
}
}
NaN means 'Not a Number'. This means that something you're referencing is, well, not a number even though you're probably intending for it to be.
Changing the timescale is generally a bad idea/practice. What is it that you're trying to accomplish?
What do you mean by 'the timescale exists'?
The NaN error probably isn't co$$anonymous$$g from this part of your script; could you post whats in your Update loop also?
Your answer
Follow this Question
Related Questions
How do I change a TextMesh's Offset Z value in JavaScript? 1 Answer
Execute code for a certain amount of time 1 Answer
Pause button 2 Answers
Finish One Combo 1 Answer