Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | BFGames | |
Old Version | Published before Godot 3 was released. |
Hi,
I’ve been playing about with Godot for about a month now, doing tutorials and testing out a few things, and have started my own mini project, but I’ve run into a bit of a problem.
Basically, I have two kinematic body types simultaneously controlled by the same inputs, and a camera that follows the average of their x positions, which works fine … to a point. However, I want to implement obstacles into the game and if one gets caught on an obstacle and the other cam continue, both of them will be out of shot.
I have a makeshift where I’ve added a third invisible kinematic body that has the average position between the two and have the camera following that, and I call a function on the first two kinematic bodies if they get too far away from the centre and they have a raycast colliding (i.e. they’re trapped because the other has gone too far).
Far from an elegant solution and one that is bound to cause problems down the line - I’ve toyed about with raycasts and viewports to create alternative approaches, but i’m at a bit of a loss now.
TL;DR: Is there a way that I can stop two simultaneously-controlled objects that share the same camera from getting too far apart and disappearing out of shot?
Thanks in advance!