Jump to content

Rotation glitching out


Borislav
 Share

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;
       }

 

Link to comment
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

Link to comment
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" :P 
like ThreeJs using right-handed with Y-up
and Unreal engine using left-handed with Z-up


 

Link to comment
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

Link to comment
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.

This PG demonstrates your issue:

http://www.babylonjs-playground.com/index.html#UMF647#5

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

For now, set rotationQuaternion:

http://www.babylonjs-playground.com/index.html#UMF647#7

 

Link to comment
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.

This PG demonstrates your issue:

http://www.babylonjs-playground.com/index.html#UMF647#5

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

For now, set rotationQuaternion:

http://www.babylonjs-playground.com/index.html#UMF647#7

 

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

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...