How do I Move a first-person 3D camera in the direction I'm looking along any/all axis?

0 favourites
  • 4 posts
From the Asset Store
Simple and easily editable template for a dynamic camera that zooms in and out based on how far apart the players are.
  • I really hope this is something simple I'm missing here...

    I'm trying to get a first person 3D camera that I can move in the direction I'm looking in 3D space not tied to a single plane of movement.

    Think like Descent... A first-person game where you use the mouse to look around anywhere in 3D space and when you push W you move towards the specific point you are looking at in 3D space.

    I've got the mouse on movement event trigging to rotate the camera with this:

    {"is-c3-clipboard-data":true,"type":"actions","items":[{"id":"rotate-camera","objectClass":"3DCamera","parameters":{"rotate-x":"Mouse.MovementX / 10","rotate-y":"Mouse.MovementY / 10","min-polar-angle":"20","max-polar-angle":"160"}}]}

    And I've got the for when pushing W:

    {"is-c3-clipboard-data":true,"type":"events","items":[{"eventType":"block","conditions":[{"id":"key-is-down","objectClass":"Keyboard","parameters":{"key":87}}],"actions":[{"id":"move-along-camera-axis","objectClass":"3DCamera","parameters":{"distance":"1","axis":"forward","which":"both"}}]}]}

    Instead of moving in the direction I'm facing though I'm just moving along a single axis regardless of where I'm looking.

    The description for the "Move along camera axis" action specifically says "Move the camera and/or look position along axes relative to the direction he camera is pointing in" but that's not what it seems to be doing.

    Any ideas?

    Thanks

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • there are multiple example projects with a camera like this, I recommend checking them out in the example browser

  • there are multiple example projects with a camera like this, I recommend checking them out in the example browser

    Can you name a specific one? Cause I didn't see anything specifically.

    First-Person platformer for example can look around and you'll move in the direction you're looking but if I look up at the sky and try to move I don't start going up in the sky - and that's what I'm looking to do - not being tied to a plane.

  • Well I figured it out...

    More polish required but in essence I did the following and it seems to work as I hoped.

    1. Added an event for W is down with 1 action:

    3DCamera - move-along-camera-axis

    distance:"10"

    axis:"forward"

    which:"both"

    2. Added an event for S is down with 1 action:

    3DCamera - move-along-camera-axis

    distance:"-10"

    axis:"forward"

    which:"both"

    3. Added an event for Mouse on Movement with 2 actions:

    3DCamera - rotate-camera

    rotate-x:"Mouse.MovementX / 10"

    rotate-y:"Mouse.MovementY / 10"

    min-polar-angle:"20"

    max-polar-angle:"160"

    3DCamera - look-at-position

    cam-x:"3DCamera.CameraX"

    cam-y:"3DCamera.CameraY"

    cam-z:"3DCamera.CameraZ"

    look-x:"3DCamera.LookX"

    look-y:"3DCamera.LookY"

    look-z:"3DCamera.LookZ"

    up-x:"0"

    up-y:"0"

    up-z:"1"

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)