Jump to content

[SOLVED]FollowCamera Weirdness


Raggar
 Share

Recommended Posts

Let's use this PG as an example:

http://www.babylonjs-playground.com/#1PX171%2323

(WASD keys).

Driving forward makes the camera follow the vehcile properly from a distance behind it.

Now, when you go backward, the camera shifts direction and follows the vehicle from the rear end. I do not want this particular functionality in my example.

I've looked through PG's, and they don't seem to have this issue. Another example is the Distraction Demo:

https://www.babylonjs.com/demos/distraction/distraction.html

I don't see any changes to the FollowCamera code base between these two versions of Babylon, and even if I use the same (default) settings, the weirdness remain.

Is there any way to keep the camera fixed, without having to recreate a followcamera myself?

Link to comment
Share on other sites

@Nesh108

I'm already using the FollowCamera implemented into Babylon.js. I'm just not sure where the camera accounts for the speed or direction of the mesh, as the camera should stay behind the mesh at all times, instead of moving in front of it when the mesh is moving backwards.

Link to comment
Share on other sites

  • 3 months later...

I went back to this issue and created a simpler PG to play with:

http://playground.babylonjs.com/#635DDW

I noticed the followCamera was sort of fighting over control with the top of the box, and then gave up and went to the left side of it.

Adding a rotation to the quaternion in the registerBeforeRender loop seems to fix the issue:

http://playground.babylonjs.com/#635DDW#1

Line 130: babylonCarBox.addRotation(0, -Math.PI/2, 0);

http://playground.babylonjs.com/#635DDW#2

Solved. Or at least fixed :P

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