Borislav Posted April 11, 2017 Share Posted April 11, 2017 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; } Quote Link to comment Share on other sites More sharing options...
hunts Posted April 11, 2017 Share Posted April 11, 2017 can you please make a pg to demonstrate this, it's much easier to work this out Quote Link to comment Share on other sites More sharing options...
Borislav Posted April 11, 2017 Author Share Posted April 11, 2017 2 hours ago, hunts said: can you please make a pg to demonstrate this, it's much easier to work this out http://www.babylonjs-playground.com/index2_5.html#UMF647#1 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted April 11, 2017 Share Posted April 11, 2017 Rotation angle are in radians not in degree Quote Link to comment Share on other sites More sharing options...
Borislav Posted April 12, 2017 Author Share Posted April 12, 2017 16 hours ago, Deltakosh said: Rotation angle are in radians not in degree Ugh, how do I write radians in js even -.- Quote Link to comment Share on other sites More sharing options...
aWeirdo Posted April 12, 2017 Share Posted April 12, 2017 @Borislav Math.PI a full rotation = 2 * PI's http://www.babylonjs-playground.com/#3YCNKQ So 90* angles are at.. (0) (-Math.PI / 2) Mesh (Math.PI / 2) (-Math.PI OR Math.PI) Quote Link to comment Share on other sites More sharing options...
adam Posted April 12, 2017 Share Posted April 12, 2017 function degreesToRadians(degrees){ var radians = degrees * Math.PI / 180; return radians; } Quote Link to comment Share on other sites More sharing options...
Borislav Posted April 12, 2017 Author Share Posted April 12, 2017 Ugh, it is still spinning with radians. Quote Link to comment Share on other sites More sharing options...
aWeirdo Posted April 12, 2017 Share Posted April 12, 2017 @Borislav BabylonJs is left-handed, meaning, the Y axis is up, in your PG, you are applying rotation to the Z axis Quote Link to comment Share on other sites More sharing options...
jschwuch Posted April 13, 2017 Share Posted April 13, 2017 @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 Quote Link to comment Share on other sites More sharing options...
aWeirdo Posted April 13, 2017 Share Posted April 13, 2017 @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 Quote Link to comment Share on other sites More sharing options...
Borislav Posted April 13, 2017 Author Share Posted April 13, 2017 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 Quote Link to comment Share on other sites More sharing options...
Borislav Posted April 14, 2017 Author Share Posted April 14, 2017 like pls it is not solved. Quote Link to comment Share on other sites More sharing options...
adam Posted April 14, 2017 Share Posted April 14, 2017 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 Wingnut and GameMonetize 2 Quote Link to comment Share on other sites More sharing options...
Borislav Posted April 14, 2017 Author Share Posted April 14, 2017 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.