0

I've got a game where you place towers on the map, it's working fine they can click and the towers place the the build mode is set to false. I Want to allow the player to hold shift down then they can place multiply towers then when they release shift the build mode will change to false but i can't figure it out.

This is what i've got so far but doesn't seem to work as intended

func _input(event):
    if event.is_action_released("ui_accept") and build_mode == true:
        verify_and_build()
    if event.is_action_released("multi_build"):
        cancel_build_mode()

I've assigned ui_accept to left click and multi_build to Shift

Exoon
  • 1,513
  • 4
  • 20
  • 35

1 Answers1

0

You are going to get a call to _input per input event. And the event object you get as parameter in _input represents that single input.

If want to to this with the event object, it would be something like this:

func _input(event):
    if event.is_action_pressed("multi_build"):
        build_mode = true
    if event.is_action_released("multi_build"):
        build_mode = false

Alternatively, you can use Input to check if the action is currently pressed: Input.is_action_pressed("multi_build").

Theraot
  • 31,890
  • 5
  • 57
  • 86