Posted By
|
Message
|
Thomas DaSilva
Registered 10/06/2014 20:15:05
Points 4
|
10th June, 2014 at 10/06/2014 20:17:29 -
I have a camera object that centers on my main player. When the player grabs onto a rope swing, the sprite snaps in position to the swing to create the appearance of the player's hand holding onto the tip of the rope. When this happens, I have written events that direct the camera object to "re-center" on the sprite, so for instance if the player collides with the swing and the camera's position is, at that instance, to the left of where the sprite snaps, the camera moves to the right until it centers on the sprite's new position).
This routine works smoothly. Where I am having trouble is as follows: when the player jumps off the rope, I need the camera to recenter again using the same routine, but since the player is now free to move about the playfield instead of confined to a static spot, I can't set a constant rate for the camera to catch up to him. For instance, if the player is moving 8 px/frame to the right and the camera 5, then the camera can't catch up, but if the player is moving right at 2px per frame and the camera moving at 5, when it does catch up it will recenter with an unpleasant visual jolt.
Does anyone have any suggestions for making the camera recenter smoothly regardless of my character's speed?
n/a
|
One Man Army Games Possibly Insane
Registered 23/10/2011
Points 2036
|
10th June, 2014 at 10/06/2014 23:07:00 -
Use the distance equation for basic cameras in MMF2.
2 Camera Objects
1st Camera object:
Always
>Center position frame to (Camera2)
>Set (Camera1) to the position of your main character
*************************************************
2nd Camera object:
Always
>Xpos(Camera1) + (Xpos(Camera2) - Xpos(Camera1))* 0.09
>Ypos(Camera1) + (Ypos(Camera2) - Ypos(Camera1))* 0.09
*************************************************
You don't have to worry about the speed because it smoothly locates the object quickly depending on the distance.
http://www.OneManArmyGaming.com
|
Thomas DaSilva
Registered 10/06/2014 20:15:05
Points 4
|
11th June, 2014 at 11/06/2014 15:04:57 -
This makes the camera smoothly follow the player, but now when the sprite snaps to the rope, the camera snaps right to it. Basically what I'm asking is, if I teleport my player between two points such as X=100 to X = 300, can I have the camera move smoothly from X=100 to X=300 at time of teleport? The way it is now, the camera just teleports too.
n/a
|
|
|