From 3ed5257c222f34b591b744ef6418b5c1165be25f Mon Sep 17 00:00:00 2001 From: J08nY Date: Sat, 22 Apr 2017 16:58:23 +0200 Subject: Camera now rotates around worlds --- scripts/camera.gd | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 scripts/camera.gd (limited to 'scripts/camera.gd') diff --git a/scripts/camera.gd b/scripts/camera.gd new file mode 100644 index 0000000..e29ad51 --- /dev/null +++ b/scripts/camera.gd @@ -0,0 +1,26 @@ +extends Camera + +var selected = null + +func _ready(): + pass + +func select(what): + if self.selected != what: + set_translation(what.translation + Vector3(1,3,0)) + look_at(what.translation, Vector3(0,1,0)) + self.selected = what + +func reselect(): + if self.selected != null: + look_at(self.selected.translation, Vector3(0,1,0)) + +func rot_around(amount): + if self.selected != null: + var relative = self.translation - self.selected.translation + var rotated = relative.rotated(Vector3(0,1,0), amount) + set_translation(self.selected.translation + rotated) + reselect() + +func get_selected(): + return self.selected \ No newline at end of file -- cgit v1.2.3-70-g09d2