0 votes

Me and my friend are making a game and it has multiple characters, one thing I've been trying to figure out for 2 days is how can I make the camera be in between multiple ( more than 2) characters and zoom in when they are close to each other and zoom out when they are further away. It is like a fighting platform game where multiple characters survive by killing one another, it's kinda like smash. But how do I get the camera to do all that?

in Engine by (16 points)

1 Answer

0 votes

The first thing that pops in my head is to use the distance_to() method between all the characters and then base the camera distance off the characters that are furthest away.

Something like:

func _process(delta):
    var A = Player1.distance_to(Player2)
    var B = Player1.distance_to(Player3)
    var C = Player2.distance_to(Player3)
    var far_characters = max(A,B,C) 
    Camera.look_at_from_position(Camera_position * Vector3(1,1,far_characters), target_look_location, Vector3(0,1,0))
by (341 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.