0 votes

HI All, I need some ideas. I have a RTS type setting featuring the character node with a high-angle camera looking at it. I can move and rotate the camera independent of the character to survey the map in its vicinity (using WASD and mouse). I want to stop the camera from moving too far away from the character node (to prevent the player from flying over the whole map without the character even going anywhere).

I tried to do this using distance_to (with a cam movement speed variable being set to 0 once a certain distance is reached) which does stop the camera movement but also prevents me from WASD-ing back to the character because the max distance condition is still met and cam movement speed is still 0.

Perhaps someone can think of a better approach?

in Engine by (433 points)

1 Answer

0 votes

Might be a good use for the built-in clamp(value, min, max) function, called once per frame on a variable that keeps track of the camera's positional offset. It takes floats, though, so I'm not sure what the specific implementation would be.

by (680 points)
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.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.