Jump to content

FPS - Can't go straight with Cannon.JS


JBP
 Share

Recommended Posts

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 ?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

@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 ?

Link to comment
Share on other sites

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 :):D 

Thanks for all the help !!

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...