physx beginner: keep camera position constant relative to an object

Started by
3 comments, last by Crazyfool 14 years, 5 months ago
nvidia physx: i have an "actor" and the camera. i get the "actor" position: Nxvec3 = actorPos; actorPos = actor->getGlobalPosition() ..... and set the position of the camera on: gCameraPos = actorPos + NxVec3(0,0,-2); ..... but this position remain only on first frame. How i make the camera keep ALL THE time this position relative to the "actor"
Advertisement
Have you checked that this code is actually run every frame?
this is what i ask..
how i update the camera position on every frame to "actor" position (or other moving actor)...

i mean.. i need for some simple lines of codes examples which could be (for advanced ones) easy or obvious...
i am to level were i experience put some objects on scene on some coord, move ahead , move back..., change settings, change functions, arguments, update camera coordonates after diferent actors...etc ..hundreds of things like this...
i don't know...it is imposibe ?
i use to work with havok in shockwave and the nine words of code for this , in lingo, was:

on enterframe me
cam.worldposition=object.worldposition
end

..and was one of the first thing which you learn on EVERY tutorial from net ...
because was one of the essential things you should work with in characters scene buildings....: the "attach" camera from a moving actor.
it is so hard in nvidia c++ physx to do this?
or imposible...?
so that NOBODY could give me a minimal sugestion.....
m_cio, Zahlman gave great advice. If that code works for one frame, there is no reason why it wouldn't work for every frame. You need to make sure that the code is executed every single frame.

If you are a making a game, you probably have some sort of game loop. Put this code in the game loop (ideally in some abstracted way to work with any actor you want to attach the camera to).

This topic is closed to new replies.

Advertisement