Camera Control Adjustment
Tosanu
Member, PRO Posts: 388
For my platformer, I am trying to control the camera's movement so that the player can see more than half the screen in front of him. As it is, i have the camera attached to an invis actor constrained about 1/4 of the screen distance in front of the player, so that as he walks right, he stays around 1/3 from the left. However, I dont know how to adjust this when he turns right. Theoretically, i could change the constraining whenever he turns (I have a FaceRight boolean), but that would cause nightmare with the camera jerking back and for, id think, especially if he has to turn repeatedly. Is there a better way for me to adjust this so that the player stays behind the center of the scene no matter which way he is going?
Comments
I'm not sure off the top of my head, I'm sure it would take experimentation. But if you did want to try what you mention above with the FaceRight Boolean, instead of having the screen just jump there. Maybe have it Interpolate from the FaceLeft to the FaceRight so the camera pans over to show the screen.
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
Interpolation, now theres something I didn't think of. I'll try it and see how it works.
It actually does a pretty good job of it. I had to tweak the code to make sure things stay in place. I put a timer after the interpolation in both the Do and Else fields, to match to exactly the time of the interpolation with a Constrain to (Position matching interpolation's destination) inside. Its a bit uneven, but thats just something ill need to fix with the distance, camera scroll zone, and interpolation speed. Thanks for the suggestion!
Cool, glad it looks workable.
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
This is very clsoe to working, but after some testing, this fix has a flaw in it.
The problem is that i have to get the camera to move to its new position and then stick there. The option i have works...unless you turn back and forth relatively quickly. It seems to mess up the interpolation. if i have a character turn right-left-right and move right hell walk right off the screen and then the image will suddenly snap into the constrain position rather than scroll. Is there something i can do to make the interpolation work, or get this scrolling action to work without interpolation, since i think its layering interpolation commands that is causing the trouble.
To add to the post, things i have tried is setting a timer on how quickly the interpolation begins to hopefully prevent early scrolling and whatever contradiction makes the camera stop, no good, or setting the camera to react to motion rather than the direction the player is working (which really just completely messes up its ability to move). My fear is that this is in the interpolate function itself, and i really want to use something of that nature due to the decent panning effect it gives to moving the camera forward or backwards.
Also, im a bit worried that it seems to be draining resources to have the interpolation. I cnat be sure since Windows editor doesn't have a tracker, but I swear my frame rate has fallen across the board on my editor preview window since I enacted this. Can anyone confirm if this is likely either?