I'm using the standard fps character controller and have a simple fly through script attached to it..
// fly script
var change:double = 3; // Determines how quickly you move
private var targetPosition:Vector3;
function Update () {
if (Input.GetMouseButton(0)) {
transform.position = transform.position+Camera.main.transform.forward
*change ;
}
if (Input.GetMouseButton(1)) {
transform.position = transform.position-Camera.main.transform.forward
*change ;
}
if (transform.position.y <0) {
transform.position.y = 0;
} }
It works well, and I can fly around the scene but am unable to go below zero. How would I adjust this? I have tried setting gravity to zero in the controller settings but still cannot fly below zero.
asked
May 15 '11 at 07:56 AM
gordonramp
11
●
8
●
10
●
14
Don't bother, I worked it out..
if (transform.position.y <-20) { transform.position.y = -20; }