- Home /
Question by
whalleyboi · Dec 18, 2012 at 09:31 PM ·
androidphysicsplane
Android: Plane physics/movement
Hello All, I am trying to create basic plane physics for the Android device. The main problem I am having is the controls. I know about Input.acceleration but if I use the raw input then the plane gets very sensitive with every little shake or movement from the users hand. I need movement to be fluent and controllable in a hand held device while being able to see the world in front of you. Any help would be greatly appreciated. Thanks!
var turnSpeed: float = 90;
var moveSpeed: float = 5;
private var controller :CharacterController;
controller = gameObject.GetComponent(CharacterController);
var localRotation: Quaternion;
var speed : float = 1.0f;
function Start() {
localRotation = transform.rotation;
}
function FixedUpdate()
{
// find speed based on delta
var curSpeed = Time.deltaTime * speed;
// first update the current rotation angles with input from acceleration axis
localRotation.y += -Input.acceleration.y * curSpeed;
localRotation.x += Input.acceleration.x * curSpeed;
// then rotate this object accordingly to the new angle
transform.rotation = localRotation;
var movement = Vector3.forward * Time.deltaTime * moveSpeed;
controller.Move(movement);
}
@script RequireComponent(CharacterController)
Comment
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Photon networking doesn't sync 0 Answers
Run again activity Android Plugin 0 Answers
Blackberry unity game not loading up 1 Answer
How to create AssetBundles for both IOS and Android 1 Answer