Hi, I am rather new at Unity. While learning and studying the available examples. I had this idea for a small challenge, specially suitable for beginners. Go to the island demo and change the FPSWalker script so you can fly around the island like Superman! Sadly, it took me a long time until I figured how to do that. But at the end I did it, so if anyone is interested I can put my solution.
Ok, sorry, here it is Following is the code that must replace the FPSWalk script on the Island demo so you can fly around the island Code (csharp): // This script is used to fly in the island demo // Replace this script under the First Person Controller Prefab // You must assign the cam var to the Main Camera on FPS Controller Inspector // // The character flies in the direction he is looking at when you press "t" // When you release the key, the character decelerates and eventually stops on mid-air // Acceleration, deceleration, maximum speed private static var acc = 0.5; private static var decel = 0.75; private static var max_speed = 25.0; var fly_speed = 0.0; public var cam : GameObject; private var moveDirection = Vector3.zero; function FixedUpdate() { // Our move direction is set to where the camera is looking at moveDirection = cam.transform.forward; // Accelerate if "t" key is pressed, decelerate if not if (Input.GetKey ("t")) { fly_speed += acc; } else { fly_speed -= decel; } Debug.Log(fly_speed); // Clamp speed between 0 and maximum speed fly_speed = Mathf.Clamp(fly_speed,0,max_speed); // Move the controller var controller : CharacterController = GetComponent(CharacterController); var flags = controller.Move(moveDirection * fly_speed * Time.deltaTime); } @script RequireComponent(CharacterController)