Sriptable camera for vert shootemup

Started by
14 comments, last by Specchum 17 years, 10 months ago
Quote:Original post by Specchum
The issue is that because it's interpolating translations the camera tends to run at different speeds than the player. How do I get around this problem?


Why is that a problem - could you clarify a little? You're moving the camera along a scripted path, right? If it gets to the position it's supposed to be at, at the time it's supposed to be there, then it all seems fine and dandy to me... :)

If the interpolation is resulting in unwanted accelerations and slowdowns (a problem I encountered using simple cubic interpolation), you might want to use another type of interpolation, such as hermite interpolation. Check Paul Bourke's excellent website for more info on that:

http://astronomy.swin.edu.au/~pbourke/other/interpolation/index.html
"Morituri Nolumus Mori"
Advertisement
The thing is that while the camera is following the path it is also tracking the player. That is, if the player begins running forward, the camera begins interpolating forward along the scripted path. When the player runs backward the camera begins interpolating backwards along the scripted path. Player runs right, camera rotates right. Player runs left, camera rotates left.

However, when the player starts running and I begin interpolating, the camera doesn't seem to match the speed of the player - the camera invariably speeds up too much or slows down too much wrt player. How do I get around this?
"There is no dark side of the moon." - Pink Floyd
Uh... fix your control points and/or interpolation?

Cameras aren't so magical that we can just say "call DirectXSlowDownCameraMovementALittleBit() and it will fix your problem." There could be literally hundreds of things going on that lead to your perceived problem.

The best useful advice to be offered is to analyze the numbers by hand: compare the speed/movement that you want to what you actually get. Then figure out where the discrepancy comes from, and address it. That's not something anyone will be able to do from the outside without complete access to your system and code.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

Quote:Original post by ApochPiQ
Cameras aren't so magical that we can just say "call DirectXSlowDownCameraMovementALittleBit() and it will fix your problem."


I figured that was the case. :)

Anyhow, let me clarify that I'm not having a problem with interpolating the camera. It interpolates between 2 points using deltaTime as is usual. My problem lies in the apparent flaw in logic I'm applying in moving the camera wrt to player. In pseudocode, I do this:

1) If key Forward is pressed, move player forward by x units (ie frame dependent movement {for now}).
2) Begin interpolation of camera along path in the forward direction.
3) Move camera to new interpolated point.
4) Repeat as above for backward movement.

The issue is that my camera doesn't remain a fixed distance from the player as the case should be for a third person camera. This I figure is due to the fact that while the player is moving by a fixed unit, the camera is moving to an interpolated point that is generated independent of the position of the player. I guess the right question would be to ask "how do I interpolate while maintaining a fixed distance from the player"? Or am I missing the point completely?



"There is no dark side of the moon." - Pink Floyd
Easy: interpolate the "ideal" camera position P along the preset control path from point A to point B. Once you know P, draw a vector from the player's position to P. Normalize that vector, then scale it by the distance you want the camera to have from the player; that's your final position.

Careful with objects passing between the camera and player, though; it might look like crap if this accidentally stuffs the camera into a wall or something [wink]

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

Right. I'll have a go at that method and see if it works then!
"There is no dark side of the moon." - Pink Floyd

This topic is closed to new replies.

Advertisement