Treating like first person view

    Oct 04 2012 | 4:18 pm
    Hi there, I am trying to create a patch that allows the to act as first person view for the user. The first thing I want to achieve is attaching a jit.phys.body to the camera so that it will interact with objects within the world box and also to constrict camera movement within the world box.
    Secondly I want to be able to stick the camera to the ground to stop the user from being able to fly around the world box.
    I've tried a few things but can't seem to achieve what seems like it should be fairly easy with the new physics engine.
    Here is what I have so far.

    • Oct 04 2012 | 7:07 pm
      to link a and a phys.body to the same, you will want to create a parent anim.node, and two child anim.nodes. the controls the parent anim.node, and the two child nodes are bound to the and the phys.body.
      the body should have @kinematic 1 enabled, allowing you to set it's transforms with the attached anim.node.
      this will allow the camera to collide with other objects in the scene, causing them to bounce off the camera, but it won't prevent the camera from going through those objects if they are static. you will have to handle this yourself, by checking for collisions with those objects.
      the patch below demonstrates this.
      you could also try a completely different approach, by linking a to a dynamic phys.body (not a kinematic one) and move it with forces and impulses. you probably want to add a phys.6dof constraint to the rigidbody to keep it upright.
    • Oct 04 2012 | 9:36 pm
      Thanks! really helpful patch and nice idea with the dynamic phys.body, I'll try and implement it as practise. With the kinematic phys.body is there any way to easily enable gravitational pull to keep the camera on the ground. and is there a way to prevent the camera from going through the walls of the Or is this something that requires clever routing of the position and collision dictionaries?
      Thanks again.
    • Oct 05 2012 | 7:37 am
      well, no not so much. you either handle this yourself by analyzing the collisions dictionary, and animating with something like, or you give in to the physics forces.
      attaching a camera to a dynamic rigid-body via a 6dof spring constraint may prove effective as well.