Why does my camera tween jump to the player?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By gdscrub

Here’s my code on GitHub.

I’m trying to get the Zelda/Megaman/Celeste-style sliding room transitions going. I’ve borrowed heavily from this Megaman project as well as from AUD_FOR_IUV’s posts on reddit (although I’m not using his style of room transition). I know there are a million ways one could go about this, but, sticking with what I have - why is it going wrong?

Specifically, my camera tween snaps to the player’s location before completing the motion. At a transition speed of 0.1 (export var, can be played with in the editor) it goes fast enough that you can’t tell, but at 1, 2, 3 seconds it’s very noticeable. The tween is attempting to move each camera limit to the next room (hard-coded for the time being) as well as the camera’s own position. In testing, this behavior happens whether I comment out the camera.position tween or not, which is extra confusing. I also have a player movement tween that’s supposed to run and move the player to the right, but it’s not working. I’ve tried turning off the player’s physics, the camera’s process that follows the player, changing the collision on the Area2D, changing TRANS_LINEAR to every other interpolation, using all different global and local coordinates, changing the order of nodes and the order of interpolations, making my own viewports, and many other things… I’m just about at wit’s end.

My code’s short and hopefully easy to parse. Just a player, camera, control node for views, and an area2d. If anyone can help me figure out what’s up I would very much appreciate it. Please let me know if you need any additional information.

:bust_in_silhouette: Reply From: bubbybumble

Something I discovered is that I had to call tween.stop_all() at the start of the new tween, because if your player is moving it has to stop the current tween midway to do the next one (assuming I understand your goal correctly). Can you show your code?

The entire project was on GitHub, but I’ve actually updated it with the working solution in case anyone - as frustrated as I was - comes along looking for help. The main problem was that I was using float position values for the Player and Camera positions, which should have been a Vector2. Thanks for the response anywho. And you’re not wrong - one of the projects I was inspired by used tween.stop_all() at the beginning as well.

gdscrub | 2020-11-23 15:24

:bust_in_silhouette: Reply From: gdscrub

I’ve answered my own question through further experimentation. The main problem was that I was using float position values for the Player and Camera positions, which should have been a Vector2. The rest is just messing around with the transition values. The working code is up on GitHub for anyone who needs help.