I am writing a top down camera code, so the player can navigate the map with WASD, Q&E. WASD are for movement, and Q&E are for zooming. My code seems not to be working, as the height is not changing in the inspector during play mode. I am thinking that it has something to do with the type of var I am using, but I cannot seem to fix it. All I want the code to do right now is for the height to change in the inspector. The number that appears in the inspector should be less than one, as the height of the camera (y value) is being divided by 100. Here is the script (so far)
var sensitivity = 1;
var lowrange = -29;
var highrange = 30;
var zoomrate = 1;
var height = 0;
function Update (){
if(Input.GetKey("d")){
transform.Translate(sensitivity, 0, 0);
}
if(Input.GetKey("a")){
transform.Translate(-sensitivity, 0, 0);
}
if(Input.GetKey("w")){
transform.Translate(0, sensitivity, 0);
}
if(Input.GetKey("s")){
transform.Translate(0, -sensitivity, 0);
}
if(Input.GetKey("e") && rigidbody.position.y > lowrange){
transform.Translate(0, 0, zoomrate);
}
if(Input.GetKey("q") && rigidbody.position.y < highrange){
transform.Translate(0, 0, -zoomrate);
}
height = rigidbody.position.y/100;
}
Sorry about the poor coding style, I script weird.
A side note- This script, when finished, will allow a dynamic camera model, so that the sensitivity will be turned down when the camera is zoomed in. This stops jerky movement when zoomed in.
Ask me if you need to clarify anything.
Javascript only, please.
-Thanks,
Thomas