i know there are alot of topics about this but i havnt found the answer to my problem
i tried to rotate my player(z axis) with rigidbody.AddTorque but when i tried to rotate him when he moves
it doesnt rotate him at all
i tried withtransform.rotate but it was unrealistic
and i dont understand how to use rigidbody.rotation(i havnt found an explanation)
i am trying to create a game like this:
http://bmxgames123.com/free-bmx-stunts-extreme.html
please help me
Does your character have a rigidbody attached to it?
Make sure you’re applying enough Torque also check if rotation is frozen or if kinematic is enabled…
i tried to put an enormus value but it still doesnt work(the rotation is not frozen and the body is not kinematic)
please help
Also check your physics settings and angular drag values if that’s not causing it… I doesn’t even knows…
And just for shifts and giggles post your script I’m willing to bet you accidently overlooked an if statement or messed up your input strings.
i havnt set a physic material
and i have included an image of my player component
here is my script:
please help me
#pragma strict
var Movespeed=0.5;
var Jumpspeed=0.5;
var Base :BaseController;
function Start(){
Base=gameObject.Find("Base").GetComponent(BaseController);
}
function Update () {
var x = Input.GetAxis("Vertical") * Time.deltaTime * Movespeed;
if(Base.isGrounded){
//rigidbody.velocity.x+=x;
rigidbody.AddForce(x,0,0);
}
left();
if(Input.GetButtonUp("Jump")&Base.isGrounded){
rigidbody.velocity.y+=Jumpspeed;
}
}
function left(){
if(Input.GetKeyUp("left")&Base.isGrounded){
rigidbody.AddTorque(0,0,9000000000000000000);
}else{
if(Input.GetKeyUp("left")!Base.isGrounded){
rigidbody.AddTorque(0,0,250);
rigidbody.AddTorque(0,0,-90);
}
}
}
please help me
i am stuck
Try overriding FixedUpdate and putting your code there instead of Update.
Try this:
public Vector3 eulerAngleVelocity = new Vector3(0, 100, 0);
void FixedUpdate() {
Quaternion deltaRotation = Quaternion.Euler(eulerAngleVelocity * Time.deltaTime);
rigidbody.MoveRotation(rigidbody.rotation * deltaRotation);
I used this too and found it here: http://unity3d.com/support/documentation/ScriptReference/Rigidbody.MoveRotation.html
those solutions dont work
please give me another solution
i’ve succeded by using rigidbody.AddTorque(); continusly
Thank you