StaticBody3D not colliding with characterBody3D

Godot Version

v4.4.stable.official

Question

I have StaticBody3D in my main map and I want it to collide with the player character only on certain conditions.

But when I’m enabling and disabling the collision with this line:

@export var collision_vystup: CollisionPolygon3D

collision_vystup.disabled = true

this code is in player script defined with:
@export var collision_vystup: CollisionPolygon3D
and played if certain area being entered if that is somehow important

collision just stops working and even if I can see the shape I can go thru it.

image of the collision shape:

image from inside the collision shape:

Does it work when you don’t disable and enable the collision? If so, have you confirmed that collision is actually enabled when it’s supposed to?

Yes the collision works. But there is another thing I forgot to mention
I don’t want the collision to be active at the beginning of the game so i disable it in the ready function of the player like this:

func _ready() -> void:
	collision_vystup.disabled = true

but when I disable this line (so collision is active from the start)
then the collision is always active even if “disabled” is set to true somewhere else in the code.

Strange is that these chages seam to be reflected visualy. It shows and disappears exactly when it should but in reality it is still there and just seem to reflect the same value it started with.

For example when the collision is enabled from the start, this happens
here I am in the area where collision should work and it does as it should


but when I leave the area the collision disappears but i can still stand on it somehow