JBP

FPS - Can't go straight with Cannon.JS

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 ?

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites

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

 

Share this post


Link to post
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 ?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
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 !!

Share this post


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

  • Recently Browsing   0 members

    No registered users viewing this page.