how to block movement and rotation and the enemy along the y axis

Godot Version

4.2.1

Question

how to block movement and rotation and the enemy along the y axis I use Character Body 3D and Collision Shape 3D how to do it there with the help of code this is my AI enemy who watches the player and kills him

In the PhysicsBody3D’s properties, you can find a group called “Axis Lock”, you can fiddle with these properties to get the desired effect. PhysicsBody3D — Godot Engine (stable) documentation in English

To set a bool flag is not option?

for example if the collision shape kills oder hits the player it is set to true.

var player_killed = false

if player killed is true when the collision hits then you check it in the movement

if(player_killed == true):
… dont move y axis anymore anymore
else:
…follow player

I need it to always be locked, that is, so that he does not move up Y and turns only left and right (only y), but x and z must be locked so that he does not turn on them