Originally Posted by Eternal Entertainment
Originally Posted by -Finn-logiq, is nice that you want to do a nice game, but what you doing is like putting others to code your game. There are a lot of articles outta there...i viewed all in 9 days
and there are 24 pages. And trust me, i found a lot of things that could help me in the future.
if you do not have spend time, read 3 or 4 pages per day...its hard but helps u much.
have a nice day!
I understand your intention for writing that, but you see, Logiq did do the correct thing. Doing that kind of camera movement correctly isn't an easy task if you've never done it before, he's not asking people to make his game for him. In this forum you are supposed to ask for help with things you can't do by yourself and those replying are supposed to give their input/help or direct the asker toward a appropriate source to solve his/her problem, otherwise, don't bother replying.
Logiq: This method should solve your problem and supersmooth too. I didn't come up with this, all credits go to Dead Man Dines and Phizzy (if DMD remembered correctly).
It is the absolutely best way for all kind of scrolling in my opinion.
DMD quote:
The method I use is as follows:
Create a new active object, which we'll program to function as a camera.
The screen will follow this object, which softly follows the player.
In properties, give it these alterable values:
--- XPOS
--- YPOS
--- RATIO (set its default value to something like 300)
We're gonna do with this what we do with float-point custom movements. We'll store the camera's X and Y position in alterable values, so they can have decimal points. It makes movement smoother and more precise.
The 'Ratio' value will be the rate of delay. 1000 will follow the player exactly, the same as 'Scroll to Player' would do. I find 300 is a good value, you'll have to experiment.
So the events are:
//Set the XPOS and YPOS values at the start, to match where we put the camera.
//This enables us to place the camera object anywhere in the level,
// and at the start of the frame, the camera will migrate from that location to the
// player. So you could place the camera at the end of the level, and the player
// at the start, and the camera will swoosh back to the player, giving a brief
// preview of the whole level.
on START OF FRAME
--- Camera: Set XPOS to 'X("CAMERA")'
--- Camera: Set YPOS to 'Y("CAMERA")'
//Now, AFTER any custom movement events, we will use a simple formula to softly follow the player:
ALWAYS
--- Camera: Set XPOS to
Xpos("CAMERA") + (X("PLAYER") - Xpos("CAMERA")) * Ratio("CAMERA")/1000.0
--- Camera: Set YPOS to
Ypos("CAMERA") + (Y("PLAYER") - Ypos("CAMERA")) * Ratio("CAMERA")/1000.0
--- Camera: Set X position to 'Xpos("CAMERA")'
--- Camera: Set Y position to 'Ypos("CAMERA")'
And that's it. All the variables, like how much the camera must move per frame, are all calculated using alterable variables, so we can keep them precise to several thousandths of a pixel. And at the end of it, we position the camera to follow those variables. This way, the movement is smooth.
The actual formula we're using is this:
cpos = cpos + (target - cpos) * r
where:
cpos = the position of the camera
target = the target position (in this case, of the player)
r = the rate of movement (a decimal value between 1 and 0, like 0.3).
How this works:
(target - cpos) finds the distance between the target (the player) and the camera's current position.
Multiplying it by the rate value gives us a percentage of the distance. This is what gives the formula its smoothness.
Finally, we add this to the camera's current position, which has the effect of moving the camera.
It works wonderfully! I love it! Better yet, you can add ANOTHER object to function as the target, instead of the player. Then, during conversations, you can reposition this target object to whoever's speaking at the time, or to important objects or cutscenes.
This way, during conversations the camera will softly swing between the two speakers.
End Quote.
Hope you people can be bothered to read all this!
//EE