Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | AceScottie1 | |
Old Version | Published before Godot 3 was released. |
so my camera is set up with self.set_perspective(fov_offset, 0.1, draw_distance) where fov_offset is 65, and drawditance is a slider from 50 to 500.
this is a 3rd person camera, i used someone elses code as a starting point but cannot find the source anymore. I have modified it a lot since then too.
the cameras center of rotation seems to be changing equle to the distance from the center of the world. if i rotate the camera around the mesh in the center of the world the mesh remins in the center of the screen, if i do the same 100 units out, the mesh can be anywhere upto 25% off the center of the screen.
center of world: Screenshot by Lightshot
100 units offset: Screenshot by Lightshot
scene hierarchy:
player >>
:>body>Pos>Camera>static body + collider(x)
:>char (male.scn)>kinimatic body (x)>collider (x)>raycast (x)
(x) = not used
#script from Camera node
onready var body = get_parent().get_parent()
onready var selfPos = get_parent()
func _update_transform():
selfPos.set_translation(body.get_translation() + offset)
var target_pos = selfPos.get_translation()
if _pitch < -1.3:
_pitch = -1.3
elif _pitch > 1.5:
_pitch = 1.5
var pos = Vector3(cos(_yaw) * cos(_pitch), sin(_pitch), sin(_yaw) * cos(_pitch))
print(_pitch)
pos *= radius
look_at_from_pos(target_pos + pos, target_pos, Vector3(0,1,0))
body is a spartial node set as perany to the mesh
selfPos is a position 3D node as a child of body
#script from body node
onready var camera = get_node("Pos/Camera")
func _fixed_process(delta):
var view_forward = -camera.get_transform().basis.z
var view_right = -camera.get_transform().basis.x
var forward = Vector3(view_forward.x, 0.0, view_forward.z).normalized()
var right = view_right