Hey Everyone, pretty new to Godot 4, still learning basics with coding and I am enjoying the experience thus far…until I get stuck.
Currently I am working on a project that uses a state machine for ability selection, then when you select an ability the state changes (physics_process(true)) then here you can choose a target. The issue I am having is when I select the target, as an example, lets just say I select move, which when I click the character does a move and slide to that location, but the moment I click the signal immediately goes to the select move state, where the physics_process(false) occurs.
I currently use physics_process(delta), and I have tried logic to determine when the character is not moving to send the signal, but it triggers immediately when you enter the state, probably because delta runs all code each frame. Is there a logic block I am missing that could be useful here? Do I have to use physics_process(delta) to even do what I am trying?
Well, how do you detect when the character is at the right place and it should stop moving?
You probably has a variable that stores the position where the character is moving, so you can check if the character’s position is equal (approx) to the target position, and you can send the signal then.
Unless I completely misunderstood what you’re trying to do
So I had an idea to set a flag for isClicked : bool, which on ready for this state will be false until you click, then checks for isClicked and then will check for the logic you mentioned above…
However, I run into the same issue, either with this logic returning true and sending the signal early, or when it does reach it’s destination the values are just barely off from one another. I’ve tried using the is_equal_approx() with this also. but when I print the values in real time to troubleshoot they seem to be off still ><
I’m almost thinking it might have something to do with trying the formula in delta?