Trying to create a binding of issac camera system

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

I’m not sure why this stops working. What I’m trying to do is increase the camera.limit_right by the camera_max_distance once I’ve reached or passed the camera.limit_right.
It works once where the camera.limit_right will increase once I’ve crossed the threshold, but then won’t work any longer.
Here’s the code:


var camera_max_distance = 224
var camera_min_distance = 0

func _physics_process(delta):
	print(camera.limit_right)
	print("Boy's position is ",position.x)

	camera.limit_left = camera_min_distance
	camera.limit_right = camera_max_distance 
	
	if position.x >= camera.limit_right:
		camera.limit_left += camera_max_distance
		camera.limit_right += camera_max_distance
:bust_in_silhouette: Reply From: zhyrin

When you change your camera limits, what you expect to happen is that your camera.limit_left becomes 224, and your camera.limit_right becomes 448. Which does happen.
But immediately in the next physics frame you set both of them back to 0 and 224.
The issue is that you set the limits every frame, which is redundant, it’s enought to update when you reach a limit.

Thanks! I moved it from the physics function and set the limits in the inspector and it worked!

pbij | 2023-02-17 23:17