Array reseting to all be the same value between ticks

Godot Version

4.6

Question

i am attempting to implement the solution in the reply to this post.

this is all the code related to said solution:

func floor_frames_update() → void:
    floor_check_frames[2] = floor_check_frames[1]
    floor_check_frames[1] = floor_check_frames[0]

    if is_on_floor():
	     floor_check_frames[0] = true
    else:
	     floor_check_frames[0] = false

func better_floor_check() → bool:
    for frame in floor_check_frames:
        if frame == true:print(“true”)
            return true
    return false

(i’m aware my code is sloppy)

the issue a am having is that it seems to only ever return either [true, true, true] or [false, false, false] and it flickers between the two when grounded witch is the exact issue i was trying to fix, i call floor_frames_upadate() at the end of my physics tick, right after move and slide.

from my debugging it seems that for whatever reason every time the code loops back to my update, the array is reset to all false or all true

(i did this by putting a breakpoint on my check returning true, then putting a break at the top of my floor_frames_upadate() and hitting f12 to see what it reads every tick)

i have checked my code, run through it over and over, plugged it into an AI at least 3 times and trying to word the question differently to get the stupid thing to tell me im dumb and point out something obvious but it just keeps asking clarifying questions.

it feels like I must be missing something but i couldn’t find anything about it online and this is kinda my last resort before just figuring out another solution.

From where are you calling those functions? Are you calling move_and_slide() between each floor_frames_update() call?

i am calling the update right at the end of my physics tick, after move and slide

...

velocity += _stored_velocity
_stored_velocity = Vector3.ZERO

move_and_slide()
floor_frames_update()

I did use ctrl f to make sure i wasent accidentally calling it from somewhere else or messing with the array in some other part of the code

I can’t replicate the issue from just what you shared.

Printing the array at the end of every _physics_process():

[false, true, true]
[true, false, true]
[false, true, false]
[false, false, true]
[true, false, false]
[true, true, false]
[false, true, true]
[true, false, true]

You could try to print_stack() in floor_frames_update() to see if it is getting called from multiple locations.

Are you sure the array isn’t shared with any other object or processing?

Frame 0 - res://Content/Player/player.gd:268 in function ‘floor_frames_update’
Frame 1 - res://Content/Player/player.gd:250 in function ‘_physics_process’

this is what i get when i put print_stack in the update, its just this over and over.

i do have some testing dummy’s that inherit from the player with checks to stop them from moving, could those somehow be messing with it?

Theoretically, yes.
If they have access to the very same array (for example via a shared resource) and update it, that would be possible.

Try to isolate the issue. Make a new scene with only the player and one StaticBody for the floor, and test if the issue persists.

I restarted worked on other parts of my project for a bit, restarted my computer and tested again after awhile and it works just fine. no idea if the stuff i did fixed it or just the restart

i was having this problem yesterday and ive obviously restarted since then, i fully reworked the movement in the meantime but none of it used any of the functions that were causing issues beyond running the check for whether or not to apply grounded physics so i haven’t a goddamn clue what the issue was.