This is the testing Godot forums! All forum posts unique to this forum will be deleted! Please use the main forums here for any posts you want to keep. All forum rules still apply.

Look around an object

pouetpouet Posts: 5Member
edited December 1969 in 3D
Hello,<br /><br />I have multiple objects in my scene and I just want to look to an object, move around the object we are looking at, and move to another object.<br />My code do almost what I want... I can move to an object and turn around, but when I move around I have a translation but not just the rotation.<br />What I do : set the rotation quaternion, move to the target and move away the camera.<br />I use linear interpolation + slerp to smooth the camera. :)<br />I think it's not the best choice but I'm a beginner in 3d. ^^<br /><br />The code :<br /><br />
<br />	var t = camera.get_transform()<br />	<br />	# Quaternion rotation + Quaternion for the camera <br />	var rot = Quat(Vector3(0, 1, 0), angle) * Quat(Vector3(1, 0, 0), ONE_DEG * 20)<br />	rot = Quat(t.basis).slerp(rot, delta * 10)<br /><br />	var end = node_look_at.get_transform().origin<br />	t.origin = t.origin.linear_interpolate(end, delta * 5)<br />	<br />	t = Transform(rot, t.origin)<br />
<br /><br />node_look_at is switched when my focus change.<br /><br />Thanks

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.