So right now, I looked up tutorials as to how to clamp my camera so that it stops at certain positions. Unfortunately, I seem to hit yet another brick wall. I added a clamp function that I thought would do it but, the thing is that when I entered certain values in the x axis, the object is hugging the left corner of the screen, even if it's possitioned to the center of the level. I only want it to do that when it's actually on the left corner of the stage. Same with the camera clamping to the right, upper and lower areas
Here's my code for anyone curious
extends Spatial
var isCameraFollowing = true
var player
func _ready():
if get_tree().has_group("Player"):
player = get_tree().get_nodes_in_group("Player")[0]
func _process(_delta):
$InnerGimbal.translation.x = clamp($InnerGimbal.translation.x, 8, 8)
$InnerGimbal.translation.z = clamp($InnerGimbal.translation.z, -5, -5)
if isCameraFollowing == true:
if player != null:
global_translation = player.global_transform.origin
else:
if player != null:
look_at(player.global_transform.origin,Vector3.UP)
if anyone can help a fellow Godot newbie out, I would appreciate it