Godot Version
Godot Engine v4.4.1.stable.steam.49a5bc7b6
Question
I am trying to make a grind rail system in my 2D game, but I am having trouble to set it up prorpely. My Grind Rail logic was to set up a Path2D, a PathFollow2D and a RemoteTrasnform, it would work as the following: when the player enters the Rail area, it would add the RemoteTransform as a child of PathFollow2D and when the Path ended or the player Jumped, it would remove the RemoteTransform child of PathFollow2D.
The problem, however, is that if i have 2 Rails or more, it will always do the Path of one of the Rails. Example: I have a Rail 1, Rail 2, Rail 3, no matter which Rail area i enter, it will always do the PathFollow of Rail 1.
Here’s The Codes:
extends PathFollow2D
@onready var RemoteTransform = $RailRemoteTransform2D
@onready var RailAim = $"../RailAim"
func _ready() -> void:
RailAim.hide()
Global.ObjectPostitions.append(RailAim)
func _process(delta: float) -> void:
if Global.CanRail:
$".".add_child(RemoteTransform)
var railSpeed := 10.0
$".".progress += railSpeed
if $".".progress_ratio == 1 :
Global.ExitedRail = true
$"../../Sonic".global_rotation = 0
$".".remove_child(RemoteTransform)
Global.CanRail = false
$".".progress_ratio = 0
if Input.is_action_just_pressed("jump"):
$"../../Sonic".global_rotation = 0
$".".remove_child(RemoteTransform)
Global.CanRail = false
$".".progress_ratio = 0
func _on_activate_path_body_entered(body: Node2D) -> void:
Global.CanRail = true
Global.ExitedRail = false
extends RemoteTransform2D
@onready var RemoteTransform = $"."
func _ready() -> void:
pass
func _process(delta: float) -> void:
if Global.CanRail:
RemoteTransform.remote_path = $"../../../Sonic".get_path()
And my nodes are arranged like this: