Fixed moving blocks
This commit is contained in:
1 parent
e7e33fa481
commit
22abac2f11
9 files changed
+135
-26
No files matched your search
+29
-11
@@ -1,21 +1,39 @@
|
||||
extends RigidBody2D
|
||||
|
||||
var max_distance = position + Vector2(1,0)
|
||||
var move_speed = 0.01
|
||||
@export var max_distance = 260.0
|
||||
@export var moving = true
|
||||
var alt_position = Vector2(position.x + max_distance,0)
|
||||
@export var move_speed = 0.01
|
||||
|
||||
func _ready() -> void:
|
||||
#Do not move collision boxes, it is fickle.
|
||||
#on_leave(%Player2D)
|
||||
alt_position = Vector2(position.x + max_distance,0)
|
||||
add_to_group("MovingPlatform")
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
print(max_distance)
|
||||
position.x = move_toward(position.x, max_distance.x, move_speed)
|
||||
|
||||
if position.x != alt_position.x:
|
||||
position.x = move_toward(position.x, alt_position.x, move_speed)
|
||||
else:
|
||||
moving = false
|
||||
%Player2D.is_on_moving_platform = false
|
||||
#%Player2D.platform_speed = 0.0
|
||||
|
||||
func on_enter(body) -> void:
|
||||
print("ON MOVING PLATFORM")
|
||||
if %Player2D.is_on_floor():
|
||||
%Player2D.is_on_moving_platform = true
|
||||
if %Player2D.is_on_floor() and body == %Player2D:
|
||||
print("Player on moving platform.")
|
||||
%Player2D.platform_speed = move_speed
|
||||
|
||||
%Player2D.is_on_moving_platform = true
|
||||
elif body == %Player2D and !%Player2D.is_on_wall_only:
|
||||
print("Player but has not landed")
|
||||
%Player2D.platform_speed = move_speed
|
||||
%Player2D.is_on_moving_platform = true
|
||||
elif body == %Player2D:
|
||||
print("SOMETHING IS WRONG WITH PLAYER")
|
||||
%Player2D.platform_speed = move_speed
|
||||
%Player2D.is_on_moving_platform = true
|
||||
|
||||
func on_leave(body) -> void:
|
||||
print("OFF MOVING PLATFORM")
|
||||
%Player2D.is_on_moving_platform = false
|
||||
if body == %Player2D:
|
||||
%Player2D.is_on_moving_platform = false
|
||||
#%Player2D.platform_speed = 0.0
|
||||
Reference in new issue
Block a user