Godot Version
4.6.1 stable
Hello, I am working on a 2D game in Godot and I structured my project with several scripts:
-
GameCharacter(extends CharacterBody2D) -
TopMovement -
InputControllerBasis -
InputController
The InputController emits a signal with a dictionary of inputs like:
{
"Left": Input.is_action_pressed("Left"),
"Right": Input.is_action_pressed("Right"),
"Up": Input.is_action_pressed("Up"),
"Down": Input.is_action_pressed("Down"),
"Jump": Input.is_action_pressed("Jump")
}
The movement script receives this dictionary and applies velocity to the character.
My scene also contains a Sea area where I want different behavior.
Question 1
How can I make the character:
-
move normally
-
not be able to jump in the sea
-
not have gravity in the sea
I would like to implement this without using a state machine.
Question 2
I also want the character to print "shoot" in the console when pressing a shoot input only when on the ground, but not when inside the sea.
What is the best way to implement this behavior?
Should I use:
-
Area2D detection
-
collision layers
-
or another approach?
Any guidance or example would be very helpful.