Jump to content

How to limit the movement of free Camera?


Alex10
 Share

Recommended Posts

Hi Alex10, good to see you again.

   Um, do you have the vehicle parented to the camera?  If so, maybe you should undo that.  :)

http://playground.babylonjs.com/#1X4ODI#2

There is a nice little vehicle-moving demo.  The vehicle is the green box, of course.  I used our following free camera, and didn't attach it to the canvas, and didn't set a standard target.  I set a special target made for the followCamera... late in the code.  I stole the mouse-on-canvas tracking code from some webpage.

This will keep your vehicles out of the mud.  :D

I am not very good at things like this, but this seemed to work ok.  My code is probably sloppy (which matches my entire life).  ;)

No clicking needed.  Move mouse right/left to turn the vehicle, and forward/backward to drive.

I'll let you study it on your own.  Our followCamera has some properties to play with, if you wish.  BabylonJS also has an arc-rotate follow cam... but I haven't tried it yet.   Hope this helps.  Be well!

Link to comment
Share on other sites

Hi again Alex.  Overhead view/close-follow view - toggle?  Easy.

http://playground.babylonjs.com/#1X4ODI#3

Line 47/48  - camera.heightOffset.  Did you experiment with this?

You CAN do this with a freeCamera, too... but you will need to write FOLLOW code if you want it to follow your vehicle.  BabylonJS cameras are very versatile (adjustable)... but sometimes it requires patience and experiments.

I am having difficulty understanding your English, sorry.

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