Changing 2 camera scripts: Problem when their target NodePath is changed inbetween

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

Hi,

I have 3 camera scripts with the feat of following the object. But When I change between pretty difference scripts(not very similar ones), it is impossible to define Node Path again.

This one is Interpolated camera:

func _physics_process(_delta):
	
	target = get_node("../Player").get_path()
#	target = get_node("../Player").get_global_transform().origin
#	var target2 = get_node("../Player/SpringArm2").get_global_transform().origin
	
	pos = get_global_transform().origin
#	if target:
	var up = Vector3(0,1,0)
	offset = pos - get_node("/root/Node/Player").get_global_transform().origin
	offset = offset.normalized() * Vector3(distance, distance, distance)
	offset.y = height
	height = clamp(height, 4, 10)
	pos = get_node(target).get_global_transform().origin + offset
	look_at_from_position(pos, get_node(target).get_global_transform().origin , Vector3(0,1,0))
	var space_state = get_world().get_direct_space_state()
	var obstacle
	obstacle = space_state.intersect_ray(get_node("/root/Node/Player").get_translation(),  get_translation())
	if not obstacle.empty():
		print(obstacle["collider"])
		look_at_from_position(obstacle.position, get_node("../Player").get_global_transform().origin , Vector3(0,1,0))
	var _look2_1 = 0
	var _look2_2 = 6
	var _look2_3 = float()
	_look2_2 -= height - 10
	_look2_3 -= distance + 40

This one from kidscancode.com. Thanks to him BTW.

> func _process(delta): 	if !mouse_control: 		get_input_keyboard(delta)
> 	$InnerGimbal.rotation.x = clamp($InnerGimbal.rotation.x, -100.4,
> 80.01) #$InnerGimbal.rotation.x = clamp($InnerGimbal.rotation.x, -1.4, -0.01) 	rotation.y = clamp(rotation.y, -100.4, 80.01) 	scale = lerp(scale, Vector3.ONE * zoom, zoom_speed)
> #	target = get_node("../Player").get_path() 	if target: 		global_transform.origin = get_node(target).global_transform.origin
> 		
> #	if arrow != null or area != null: 	arrow = get_parent().find_node("Arrow") 	arrow.global_transform.basis =
> arrow.global_transform.looking_at(get_node("/root/Node/Area").global_transform.origin,Vector3(0,1,0)).basis 	arrow.scale = Vector3(arrow_scale, arrow_scale, arrow_scale)
> 	get_node("/root/Node_PauseMenu").get_node("RichTextLabel").text =
> String(Engine.get_frames_per_second())

I’m sorry but I don’t understand what is your question here, could you explain it clearer please ?

ArthyChaux | 2020-05-07 21:43

I change between scripts and the target node is not applied after changing two scripts

Okan Ozdemir | 2020-05-08 19:51