How to get variables that aren't global

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By cvetirodrigez

I want to get the position of touch on mobile phone then move bullet there after each frame. The bullet isn’t moving much because I’m not increasing the position from process function

the bullet is area2d
func _input(event):
if event is InputEventScreenTouch:
var posOfTouch = event.position
var direction = (posOfTouch - get_global_position()).normalized()
set_global_position(direction * speed)

So how should I make it if those vars are not global?

:bust_in_silhouette: Reply From: lewis glasgow

you cant if you want to use a variable in more than one function