0 votes

So I am able to calculate weapons range and draw it on screen, now I wonder how can I calculate that distance into camera zoom ?

I wish to with melee weapon equipped set camera to zoom Vector2(1, 1), else zoom out enough for player to see full attack range of the weapon...

Let me know if you need an image to clarify what I mean.

in Engine by (87 points)

Got it working with following formula, tested on current weapons only however, not sure if it will stop working properly when I add longer range weapons.

var zoom = clamp(get_weapon().attack_range / 500, 1.5, 5)
camera.zoom = Vector2(zoom, zoom)

Please log in or register to answer this question.

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 Frequently asked questions and 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.