Before updating to Windows 10 you may need to return your Pro license. More information here

fps controller below 0 coordinate

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.

more ▼

asked May 15, 2011 at 07:56 AM

avatar image

11 33 24 26

Don't bother, I worked it out..

if (transform.position.y <-20) { transform.position.y = -20; }

May 15, 2011 at 08:40 AM gordonramp
(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments



asked: May 15, 2011 at 07:56 AM

Seen: 1027 times

Last Updated: May 15, 2011 at 04:27 PM