Godot Version
4.3 Stable
Question
extends NodeState
@onready var character_body_2d: CharacterBody2D = $"../.."
@onready var animated_sprite_2d: AnimatedSprite2D = $"../../AnimatedSprite2D"
const SPEED: int = 1
var parent_node
func _ready() -> void:
parent_node = get_parent()
func on_process(_delta : float):
pass
func on_physics_process(_delta : float):
character_body_2d.velocity.x = 0
if GameInputEvents.up_input():
character_body_2d.velocity.y = -100
animated_sprite_2d.play("climbing")
elif GameInputEvents.crouch_input():
character_body_2d.velocity.y = 100
animated_sprite_2d.play_backwards("climbing")
else:
character_body_2d.velocity.y = 0
animated_sprite_2d.play("start_climbing")
if character_body_2d.is_on_wall():
print("is on wall")
else:
print("is out wall")
character_body_2d.move_and_slide()
func enter():
animated_sprite_2d.play("start_climbing")
#LevelManager.autoload_climbing = true
func exit():
animated_sprite_2d.stop()
If velocity.y moving because I press the input event, the character_body_2d.is_on_wall()
became false
this obstacle for me, because I can’t manipulate character_body_2d
movement. because currently my “Player” when in this state(“climbing”) can move up and down even he not in the wall (tile map) anymore.
Chat GPT can’t solve this situation, and she tell me it’s because the movement too fast and is_on_wall()
failed