Godot Version
Godot 4.4
Question
Hello, I have characters set up to stick on walls when they collide with them. They are able to stick and unstick, however, when I go to move them they often(not always, if I move well) restick immediately.
I was thinking a way to fix this would be to make a new variable, can_touch, setting to true on ready, and when the character touches a wall, set it to false, then making a timer set it to true again, if it’s false. However, I have been hammering away at this and I feel like I’m stalling. I cannot figure out where to place this timer. Or really if I’m heading in the right direction at all.
I have more than one character, with separate scenes and scripts. I thought I had something nailed down but it keeps starting when I don’t want it to. And before this mess that I know doesn’t work, I also tried putting it into an on func _on_input_event but… and maybe I’m just a moron but it’s a drag and drop system, so I gotta click to move and when I click on a different character, this timer starts…so I tried moving on from that option and now, for where my timer is, I have this (not sure if I worded this question decently at all, my apologies):
if touch_wall == true:
can_touch = false
if can_touch == false :
timer.start(4.5)
if prev_pos != self.global_position:
var collision_count = get_slide_collision_count()
if collision_count > 0:
for i in range(collision_count):
var collision = get_slide_collision(i)
if collision:
if can_touch:
just_touched = true
touch_wall = true
func _on_timer_timeout() -> void:
can_touch = true
Thank you for reading. I’ve posted a few other times this week and this community has been completely wonderful. I appreciate it.