# solved Rotation glitching out

## Recommended Posts

What's the problem?!

The problem is that when I try to make my character turn around to the direction he is going; instead it starts spinning three-sixty.

My code:

`````` if(controls.left){
char.position.x -= 0.1;
char.rotation.z = 90
}

if(controls.right){
char.position.x += 0.1;
char.rotation.z = 270;
}

if(controls.forward){
char.position.z += 0.1;
char.rotation.z = 360;
}

if(controls.backward){
char.position.z -= 0.1;
char.rotation.z = 180;
}``````

##### Share on other sites

can you please make a pg to demonstrate this, it's much easier to work this out

##### Share on other sites

2 hours ago, hunts said:

can you please make a pg to demonstrate this, it's much easier to work this out

##### Share on other sites

Rotation angle are in radians  not in degree

##### Share on other sites

16 hours ago, Deltakosh said:

Rotation angle are in radians  not in degree

Ugh, how do I write radians in js even -.-

##### Share on other sites

@Borislav Math.PI   a full rotation =  2 * PI's

So 90* angles are at..

(0)

(-Math.PI / 2)     Mesh     (Math.PI / 2)

(-Math.PI OR Math.PI)

##### Share on other sites

var radians = degrees * Math.PI / 180;

}

##### Share on other sites

Ugh, it is still spinning with radians.

##### Share on other sites

@Borislav
BabylonJs is left-handed, meaning, the Y axis is up, in your PG, you are applying rotation to the Z axis

##### Share on other sites

@aWeirdo the left-handedness of BJS has nothing to do with the Y-Axis beeing "up". The left-handedness means, that bigger x values mean the object moves to the left not the right. You can have a right-handed coordinate system that has Y going up too. Y beeing up instead of Z is just another design decision one has to make besides the handedness

Example for left and right handed coordinate systems from wikipedia: https://en.wikipedia.org/wiki/Cartesian_coordinate_system#/media/File:3D_Cartesian_Coodinate_Handedness.jpg

##### Share on other sites

@jschwuch
i'll have to admit you're correct ,

my previous reply was ment more as a generalisation than as "this is how it is", my bad,
if a program or script/framework uses a right-handed coordinate system, it will more often than not, also have the Z-axis up,
and if left-handed, it will more often than not, have the Y-axis up.

It mainly splits between different industries and their "traditions", while i've got no clue how it started or why..
most modeling software uses a right-handed system with Z-up and most rendering engines / game frameworks, etc uses a left-handed system with Y-up.

3DS Max is right-handed with Z-up,
Blender is right-handed with Z-up,

Unity3d is left-handed with Y-up,
BabylonJs is left-handed with Y-up, (allthough recently support to switch to right-handed with y-up was added)

and of course there are the "un-traditional"
like ThreeJs using right-handed with Y-up
and Unreal engine using left-handed with Z-up

##### Share on other sites

On 12.04.2017 at 7:27 PM, aWeirdo said:

@Borislav
BabylonJs is left-handed, meaning, the Y axis is up, in your PG, you are applying rotation to the Z axis

The thing I want to do is to make the character turn around North, South, East or West.

North = W

South = S

East = D

West = A

##### Share on other sites

like pls it is not solved.

##### Share on other sites

You would have had a faster response time if your PG was more focused.  I had to delete some unnecessary code that was causing some errors.

There appears to be a bug in BJS when setting euler rotation when using a physics in imposter.

For now, set rotationQuaternion:

##### Share on other sites

On 14.04.2017 at 2:17 PM, adam said:

You would have had a faster response time if your PG was more focused.  I had to delete some unnecessary code that was causing some errors.

There appears to be a bug in BJS when setting euler rotation when using a physics in imposter.

For now, set rotationQuaternion:

Oh my gosh! Thank you!

Edit: It flipped on it's back but it does move like it needs to but on back.

halp plox

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.