Godot Version
4.3
Question
I need some tutorials or tips on how to make my final year work
The game in question is a 2d detective game where you solve a quiz to get clues from witnesses. there is no movement, i want to know how to add a click event that starts dialogue with a character (i.e the scene changes) and consequences. if there’s any tutorial on this, please link me on it.
What exactly do you want? Detect a click anywhere on the screen? Detect a click in some specific area?
For specific areas, you can always create an Area2D, and add a CollisionShape2D child to that, and add a RectangleShape to the CollisionShape. Then connect the input_event(…) signal from the Area2D to whatever script you’re using, and use code like the following:
func _on_area_2d_input_event(_viewport: Node, event: InputEvent, _shape_idx: int) -> void:
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
print("click")
If instead you just want to detect a click anywhere on the screen, use the _input callback: In any script, write:
func _input(event):
if event is InputEventMouseButton and etc etc etc:
do stuff