Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | literallynick_ |
So, I recently followed Heartbeast’s platformer tutorial where he taught us how to do a platformer movement which I absolutely loved, I made a RayCast and then slapped code to flip the RayCast
extends KinematicBody2D
const UP = Vector2.UP
const GRAVITY = 20
const SPEED = 200
const JUMP_HEIGHT = -500
var motion = Vector2()
onready var rayCast = get_node("RayCast2D")
func _physics_process(delta):
motion.y += GRAVITY
if Input.is_action_pressed("ui_right"):
motion.x = SPEED
rayCast.cast_to = Vector2(50,0)
elif Input.is_action_pressed("ui_left"):
motion.x = -SPEED
rayCast.cast_to = Vector2(-50,0)
else:
motion.x = 0
if is_on_floor():
if Input.is_action_just_pressed("ui_up"):
motion.y = JUMP_HEIGHT
motion = move_and_slide(motion, UP)
but now I have a question.
In a Platformer Prototype I am making, I have these ladders on the left side of the platform that when you jump next to em and the raycast is colliding with them and you hold a button, its supposed to stop the movement and freeze you in place and then when you hold jump button it should move you up and then you can continue platforming.
Would really appreciate the help :"D