0 votes

I have this piece of code which is supposed to move the camera:
getparent().findnode("MenuCamera").position.x = lerp(getparent().findnode("MenuCamera").position.x, 995, 0.15)

It runs every frame so as far as I can see the camera should eventually end up at (or very near to) 995. But for some reason i stops at 412. Have used lerp() like this before without problem. Have I messed something up or could it be related to the parent node or something?

asked Dec 13, 2019 in Engine by MOSN (32 points)

What kind of camera is this? A regular Camera? An InterpolatedCamera? Maybe it has subverting to do with the camera type?

It's a Camera2D

1 Answer

0 votes

I guess:
1. the process stops before the camera goes to the expected place;
2. or the camera has the limit set as 412 in x position.
You can try to print the position of the camera to figure out the problem.

answered Dec 14, 2019 by SpkingR (90 points)

Already tried printing it and none of those two are the case.

Maybe the problem is occurred by the camera node settings.
I just test the lerp function with the code x = lerp(x, 995, 0.15) and finally the result is all right.

Whoops I found the problem. I forgot to disable another process on the parent node moving the position.x towards 0, so it was being "dragged" in two directions and 412 just seems to be where it settles.
Thanks anyways :-)

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.