#5 développement du mouvement du robot et d'une caméra qui le suit
This commit is contained in:
6
entities/camera/camera.tscn
Normal file
6
entities/camera/camera.tscn
Normal file
@@ -0,0 +1,6 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://dj7gp3crtg2yt"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://d1nsr56bh1a1y" path="res://entities/camera/scripts/camera.gd" id="1_y2wxd"]
|
||||
|
||||
[node name="Camera" type="Camera2D"]
|
||||
script = ExtResource("1_y2wxd")
|
||||
11
entities/camera/scripts/camera.gd
Normal file
11
entities/camera/scripts/camera.gd
Normal file
@@ -0,0 +1,11 @@
|
||||
extends Camera2D
|
||||
class_name Camera
|
||||
|
||||
const LERP_WEIGHT = 0.9
|
||||
|
||||
@export var following : Node2D
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
if following:
|
||||
global_position = following.global_position.lerp(global_position, LERP_WEIGHT)
|
||||
1
entities/camera/scripts/camera.gd.uid
Normal file
1
entities/camera/scripts/camera.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://d1nsr56bh1a1y
|
||||
Reference in New Issue
Block a user