Improved moving platform
This commit is contained in:
1 parent
7bcdfb1f7a
commit
2342c5b372
13 files changed
+55
-21
No files matched your search
@@ -1,11 +1,21 @@
|
||||
extends RigidBody2D
|
||||
|
||||
var max_distance = position + Vector2(1,0)
|
||||
var move_speed = 0.01
|
||||
|
||||
func _ready() -> void:
|
||||
print("START POSITION: " + str(position))
|
||||
pass
|
||||
add_to_group("MovingPlatform")
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
print("NEW POSITION :" + str(position))
|
||||
position.x = move_toward(position.x, max_distance.x, 1)
|
||||
print(max_distance)
|
||||
position.x = move_toward(position.x, max_distance.x, move_speed)
|
||||
|
||||
func on_enter(body) -> void:
|
||||
print("ON MOVING PLATFORM")
|
||||
if %Player2D.is_on_floor():
|
||||
%Player2D.is_on_moving_platform = true
|
||||
%Player2D.platform_speed = move_speed
|
||||
|
||||
func on_leave(body) -> void:
|
||||
print("OFF MOVING PLATFORM")
|
||||
%Player2D.is_on_moving_platform = false
|
||||
Reference in new issue
Block a user