About Store Forum Documentation Contact
Donations:
327$/mo



Post Reply 
camera displacement during movement
Author Message
Fab4 Offline
Member

Post: #1
camera displacement during movement
Hi guys,
the last days I tried to fix a weird camera problem, which occurs during movement of a controller.
I just want to make the camera follow the controller.
So the fist thing I tried was to use the .at function to set the position the camera should look at to the position of my controller.
Cam.at=controller.center();

As soon as the controller moves (which is moved with controller.update(vector,0,0); function) there is a displacement between relative position of camera and controller.
[Image: displacement.png]
(white shape is in static situation, green during movement to the right side)

I also tried to use the position of the actor but it doesn't change anything.

By trying to use the .setSpherical(); function, it doesn't happen anything until i set
CamHandle(0.1f, 10,NULL);
which confuses me a lot, because it it doesnt have to be set in "16 - Camera Modes.cpp" of the tutorial scripts.
Does anyone has any idea what my problem is?

Thank you for your help in advance

Fab

[thread can be closed]
I tired the only logical thing and it worked. It is a little embarrassing that I found it out by myself five minutes after posting this.

For people who have the same problem in future or are just interested in the solution:
Next to the current position of the actor you want to position the camera at, you have to add a small distance which is in relationship to the velocity of the actor.
So "+controller.actor.vel()*Time.D()" describes the kinematic relationship of this displacement and must be added to the position.
(This post was last modified: 10-22-2011 09:10 PM by Fab4.)
10-22-2011 08:29 PM
Find all posts by this user Quote this message in a reply
Dandruff Offline
Member

Post: #2
RE: camera displacement during movement
thanks for taking the time and sharing the solution smile
10-25-2011 06:12 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #3
RE: camera displacement during movement
You should not add vel*time
You should focus on order of calling:
Setting camera
Updating physics
10-25-2011 10:47 AM
Find all posts by this user Quote this message in a reply
Fab4 Offline
Member

Post: #4
RE: camera displacement during movement
Hmm I don't understand your point.

In "01 - Character.cpp" your own script is

Physics.startSimulation().stopSimulation();
player.update(); // update player
Cam.setSpherical(...);


and it works pretty good.

In my Script it looks pretty similar:

Physics.startSimulation().stopSimulation();
movePlayer();//set velocity vector of controller
dSpieler();//draw skel at deformation and position
UpdateCamera();//Update camera


But I get the displacement of the picture. But if I add an addative
"UpdateCamera;" directly after the stopSimulation it works.

Physics.startSimulation().stopSimulation();
UpdateCamera();
movePlayer();//set velocity vector of controller
dSpieler();//draw skel at deformation and position
UpdateCamera();//Update camera


in camera function there are just set 3 commands:

void UpdateCamera()
{
CamHandle(0.1f, 10, CAMH_ZOOM|CAMH_ROT);
Cam.at=Spieler.actor.pos();
Cam.updateVelocities();
}


I tried every possible order, but in my opinion the current is the only logical, because I first make the Controller move then update the skeleton and in the end I update the camera. And another weird thing is, that the skeleton is positioned exactly where the controller is, but the camera is not.
10-25-2011 07:35 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #5
RE: camera displacement during movement
why draw in update?
dSpieler();//draw skel at deformation and position
10-25-2011 09:36 PM
Find all posts by this user Quote this message in a reply
Fab4 Offline
Member

Post: #6
RE: camera displacement during movement
sry i dont know why i called it draw. it is just the animation of the bones. the drawing is of course is in void render ()
10-26-2011 04:03 PM
Find all posts by this user Quote this message in a reply
Post Reply