Godot 4.2.1
Hello. Im tryin to make camera follow position “X” between Player and mouse, something like in Top Down Shooters (Enter the gungeon, etc). I think it something with interpolation and code belowe is the most close thing I can do, but its not completly that. Im completly new to coding (absolute 0) and im very bad at math, so, is there any idea what to change in code.
Sorry, I didnt get it. What?
extends Camera2D
@onready var camera_2d = $"."
var mouse_position
var cam_position
# Called when the node enters the scene tree for the first time.
func _ready():
pass
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
mouse_position = get_viewport().get_mouse_position()
cam_position = Vector2i((mouse_position.x)/2,(mouse_position.y/2))
camera_2d.position = cam_position
Make Camera2D a child of the player
Make sure to tweak the offset of the Camera2D (-288,-162) or 1/4 of your viewport