Godot Version
4.3
Question
I want to reset my "backgrouund_tile " position and make it loop . Its working but the it creates a snap effects which is not good to watch extends Node2D
@export var pole:PackedScene
@onready var bird: RigidBody2D = $bird
@export var background:PackedScene
@onready var backgrouund_tile: Node2D = $Backgrouund_tile
@export var max_y=100
@export var min_y=-100
var gl:Vector2
var background_width: float = 0
Called when the node enters the scene tree for the first time.
func _ready() → void:
gl=backgrouund_tile.global_position
Called every frame. ‘delta’ is the elapsed time since the previous frame.
func _process(delta: float) → void:
if backgrouund_tile.global_position.x==-400:
backgrouund_tile.global_position.x=gl.x
print(backgrouund_tile.global_position)
func _on_timer_timeout() → void:
spawn()
func spawn()->void:
var new_pole=pole.instantiate()
new_pole.global_position.x=bird.global_position.x+600
new_pole.global_position.x+=50
new_pole.global_position.y=randf_range(min_y,max_y)
add_child(new_pole)