How to targetting the camera to the character in a circular motion?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By bgegg

I used to receive a code for the circular movement.
I do not completely understand, but I am in the process of learning.
Can I point the camera towards the character?
I think the camera’s local y-axis should be pointing towards the character.

extends Sprite
#直径
var R=100
var xangle
var yangle
var direction
var time = 0

var character_position

func _ready():
	pass

func _process(delta):
	character_position = get_parent().get_node("character").get_transform().origin
	
	time = time + delta * 100
	xangle=sin(deg2rad (time))
	yangle=cos(deg2rad (time))
	direction = Vector2(xangle, yangle)
	direction=direction.normalized()*R
	position = direction  + character_position

and this is video by code.
please help.

https://i.imgur.com/c4dS9sa.mp4

You mean pointing the arrow at the character?

Dlean Jeans | 2019-07-01 06:02

Thank you very much.
I’m sorry. my english poor.
That means such a movement.
red triangle is camera

enter image description here

bgegg | 2019-07-01 10:22

https://i.imgur.com/ZFBbSU5.mp4
i use look_at function.
It is not a beautiful circle
Can you make it a beautiful circle?

bgegg | 2019-07-01 11:11

:bust_in_silhouette: Reply From: Dlean Jeans

Here’s a shorter version, with customizable radius and speed in the Inspector:

extends Sprite

export var radius = 100
export var speed = PI * 0.5

onready var character = get_parent().get_node('character')

var angle = 0

func _process(delta):
	angle += speed * delta
	
	position = character.position + Vector2.RIGHT.rotated(angle) * radius
	look_at(character.position)
	rotation += PI * .5

Thank you!
It is a beautiful movement

I will apply this to 3D

bgegg | 2019-07-01 21:06