Hi people,
I can’t get why some very simple scripts work in Unity’s editor and not in exported players (standalone and web).
Here’s the stuff
No issue with draging objects script. But as mentionned, the user should be able to move the camera :
- orbital around the objects
- up and down (with a “Look at” script so that camera always points on the chair)
To do this I used :
1/ a first null object (say “null_1”) at the middle of the scene
2/ a second (“null_2”), parented to the first one and translated few meters away
3/ The camera parented to “null_2” (distance 0)
Now scripts attached :
To null 1 :
var RotateSpeed = 2.0;
function Update () {
var h = RotateSpeed * Input.GetAxis ("Horizontal");
transform.Rotate (0, h, 0);
}
To null 2 :
var verticalSpeed = 2.0;
function Update () {
var v = verticalSpeed * Input.GetAxis ("Vertical");
transform.Translate (0, v, 0);
}
To camera :
var target : Transform;
function LateUpdate () {
// Just lookat
transform.LookAt(target);
}
(where target is null 1)
“Vertical” and “Horizontal” are setted as arrow keys in the input panel.
It works perfectly in Unity’s editor. Not in players.
What’s wrong ?
What is curious is that I used almost the same scripts for a similar camera nav in another project.
HERE
In this second scene the scripts are a bit different because I need some horizontal translation for my “null_1”
Thus they are setted as follows :
null 1 :
var RotateSpeed = 2.0;
var TranslateSpeed = 2.0;
function Update () {
var h = RotateSpeed * Input.GetAxis ("Horizontal");
transform.Rotate (0, h, 0);
// ADDED
var v = TranslateSpeed * Input.GetAxis ("Vertical");
transform.Translate (0, 0, v);
}
null 2
var verticalSpeed = 2.0;
function Update () {
// ADDED
var v = verticalSpeed * Input.GetAxis ("Jump2");
transform.Translate (0, v, 0);
}
(“Jump2” = R and F keys)
camera > “look at” script
And it works…
By the way there are no difference in input preferences settings from the first scene to the second one… they both are stored in the same Unity Project anyway.
Any help ?