My sprite is not at the correct Y position when following mouse / touch

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

Hi all,

Here is a video showing the problem.

Here is the code, attached to an Area2D. Godot3.0 on Ubuntu.

func _on_Area2DLeftAim_input_event( viewport, event, shape_idx ):
	touchPOS = event.global_position
	$aimingStick/support/target.position.y = touchPOS.y
	print("Touching: ", str(touchPOS))

Can anyone offer any advice as to what’s making it go wrong? Thanks so much…

:bust_in_silhouette: Reply From: Dlean Jeans

I guess it should be global_position

$aimingStick/support/target.global_position.y = touchPOS.y

Alternatively, try these two nodes: VSlider and VScrollBar since they work like what you’re trying to make.

Perfect! Thank you. So obvious once you show it. Much appreciated my friend

Robster | 2018-02-19 09:09