Question

I have a camera class and i want it to be able to track a physics object. However in my game engine (which is what the camera class will be part of), you can use different physics engines (even some i did not develop). How can i make my camera capable of tracking an object regardless of the physics engine i am using? if it helps, i will have a wrapper class to help abstract some of the specifics of dealing with specific engines physics implementation.

Was it helpful?

Solution

Wrap your object with something that contains a standard position object (Probably a Vector3). Then, simply add a Camera.LookAt(GameObject) method that will allow you to track the object. Also, this is nice to use with other objects in your engine, it simply gives you the ability to follow any object with any camera. This is the method I have used in my two previous game applications.

OTHER TIPS

This completely depends on how your graphics engine is setup.

Most graphics engines have some form of scene graph, and a way to attach a camera to a node in the scene graph. This will make the camera inherit the transform's of it's parent, which means it can easily "follow" around another node.

If the physics system integrates cleanly, it'll move the objects around the scene, which effects their node. This will automatically propagate into the camera.

I could potentially give you more specifics, if you want to specify the game engine + physics integration packages you are using.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top