![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | whywhyw |
i knew the answer to my question but i forgot it so thats why im asking.
![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | whywhyw |
i knew the answer to my question but i forgot it so thats why im asking.
![]() |
Reply From: | ramazan |
func _input(event):
if event is InputEventMouseButton and event.button_index == BUTTON_RIGHT:
if event.pressed:
print("kkkk")
///////////// follow
https://forum.godotengine.org/40507/solved-enemy-follow-player
![]() |
Reply From: | skysphr |
You can either use _input()
and change states between following and non-following or directly call Input.is_mouse_button_pressed()
inside _physics_process()
.
var following: bool
func _ready():
following = false
func _input(event):
if event is InputEventMouseButton and and event.button_index == BUTTON_RIGHT:
following = event.pressed
func _physics_process(delta):
if following:
position += get_local_mouse_position().normalized() * follow_speed * delta
func _physics_process(delta):
if Input.is_mouse_button_pressed(BUTTON_RIGHT):
position += get_local_mouse_position().normalized() * follow_speed * delta
(untested code but it should work)