I am trying to write a script for a hover board.
The problem I’m having is rotating the board to the position the player is facing, and ,
(the board is hovering so there is no drag) moving the board in the correct direction.
Currently the character turns but not to the direction of travel.
var moveX : float = 0.0;
var turnForce : float = 10.0;
function Update () {
moveX = Input.GetAxis ("Horizontal");
rigidbody.AddTorque(Vector3.up * (moveX * turnForce * Time.deltaTime));
// turning but 'sliding' , add relative force to 'push' in new direction
rigidbody.AddRelativeForce(Vector3.right * (moveX * turnForce * Time.deltaTime));
}
Even if I make a vector which I want the object to face, I don’t know how to rotate or add torque to face that point.
(this is more of a general comment rather than a question) :
I’m having great difficulty understanding how to rotate my characters in any scripts, with either method (transform or rigidbody).
I just cannot get my head around local space and world space in relation to any of the transform rotation Quaternian Slerp stuff, or the physics rigidbody addTorque stuff.
here is the project : http://www.alucardj.net16.net/unityquestions/hoverboard%201-1a.html
here is the full script : http://www.alucardj.net16.net/unityquestions/ScriptHover1-1a.js
(note: the textures and objects are basic =] , I am just using them to write the script , and for now the rigidbody constraints are on for rotation X and Z)