3d camera limit

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

Hi,

How can I able to add a limit on a 3d camera? Just like the limit on the 2d camera.

Thanks!

:bust_in_silhouette: Reply From: klaas

Hi,
you have to implement that on your own by scripting, like so …

var my_upper_x_limit = 100
var my_lower_x_limit = -100

func _process(delta):
    if global_transform.origin.x > my_upper_x_limit:
        global_translate( Vector3(0,0,my_upper_x_limit - global_transform.origin.x) )
    elif global_transform.origin.x < my_lower_x_limit:
        global_translate( Vector3(0,0,my_upper_x_limit - global_transform.origin.x) )
    
    # do this for any restricted axis