JBP Posted September 13, 2016 Share Posted September 13, 2016 Hello I have submit a question in the Questions & Answers sections: But I my problem is not in decode but in the BABYLON.JS Resume: The control works but the problem is that the camera/hero doesn't go straight forward all the time. Example if at start I point at the Box at the top left if and only press 'W' it goes straight to the Box, but if I for example go straight 'W' for 1-5 seconds and then point at the Box and press 'W' the camera/hero doesn't go straight to the BOX, it goes sides ways. Can anyone please check this out ? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 13, 2016 Share Posted September 13, 2016 Hey! we will need to a simple repro case in the playground to help you out:) Quote Link to comment Share on other sites More sharing options...
JBP Posted September 13, 2016 Author Share Posted September 13, 2016 Hello, thanks for the reply there are two examples: http://www.babylonjs-playground.com/#1AFY3M#0 http://www.babylonjs-playground.com/#1AFY3M#1 The control works but the problem is that the camera/hero doesn't go straight forward all the time. For example if at start I point at the Box at the top left if and only press 'W' it goes straight to the Box, but if I for example go straight 'W' for 1-5 seconds and then point at the Box and press 'W' the camera/hero doesn't go straight to the BOX, it goes sides ways. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 14, 2016 Share Posted September 14, 2016 This is because you activated physics. When colliding with the box, the sphere tries to avoid collision and then slides to the left or the right Quote Link to comment Share on other sites More sharing options...
JBP Posted September 14, 2016 Author Share Posted September 14, 2016 Sorry i don't understand what you wrote. There are only three meshes with physics the hero, ground and the box. There sphere that appears in the middle of screen is just an aim sight, so that the user know where its shooting, and was no physics enabled. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 14, 2016 Share Posted September 14, 2016 The hero is colliding with the box Quote Link to comment Share on other sites More sharing options...
Raggar Posted September 14, 2016 Share Posted September 14, 2016 @Deltakosh I think what he means is the following: Run the scene, and press forward for a couple of seconds 'Before!' using the mouse to aim. Then use the mouse to aim at the box. Now, when you press forward again, you don't move straight forward, but has some weird force going right as well. JBP 1 Quote Link to comment Share on other sites More sharing options...
JBP Posted September 14, 2016 Author Share Posted September 14, 2016 @Raggar is correct Ok you are correct but the problem is before the collision. At the start if you aim at the box and press W it goes straight to the box. But if at start you go straight (W) for 1 - 5 seconds and then you aim at the box and press W its does not go straight to the box it goes sideways. Its a problem difficult to explain to you think a video can help ? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 14, 2016 Share Posted September 14, 2016 Ok gotcha..Did you try without physics? just by moving object's position Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted September 14, 2016 Share Posted September 14, 2016 because your not accounting for the offset of the forward in worldspace. Quote Link to comment Share on other sites More sharing options...
JBP Posted September 14, 2016 Author Share Posted September 14, 2016 @Pryme8 OK cool, but how do I do that ? Or can you update my playground ? Quote Link to comment Share on other sites More sharing options...
JBP Posted September 14, 2016 Author Share Posted September 14, 2016 @Deltakosh Hello I have update the playground with no physics and the hero goes always straight. http://www.babylonjs-playground.com/#1AFY3M#3 So I don'y know if this is a BabylonJS bug or a Physics Bug I have tried OimoJS also and the result is the same. Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted September 15, 2016 Share Posted September 15, 2016 Look for TERIABLE infinity or magic marble editor demo, both will show you how to set up a physics controller including grounded state events. the TERIABLE Infinity has controls for no gravity, crouching and running. Quote Link to comment Share on other sites More sharing options...
JBP Posted September 16, 2016 Author Share Posted September 16, 2016 Found the solution, the problem is not in BabylonJS the problem is in this lines of code: hero.physicsImpostor.physicsBody.fixedRotation = true; hero.physicsImpostor.physicsBody.updateMassProperties(); I was creating a Cylinder and fixing the rotation so that the cylinder was always up, if remove these lines and replace the Cylinder with a Sphere starts to work Thanks for all the help !! 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.