Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | MaximoTG98 |
So in my last question in this Q&A(just look the node tree), I was confused why it didn’t work, now I made only a scene with the bare minimun nodes to replicate the other issue, and I found out that the TextureRect I have, blocks que collisionshape in some sort of weird way, my intention was to drag a card around the screen, I used TextureRect because I do not have sprites that fit into the box and texturerect does that job for me, well, after attaching the Area2D to itself with the signals mouse in/out and in it’s script:
extends Area2D
var mouse_in = false
func _process(delta: float) -> void:
if mouse_in && Input.is_action_pressed("left_mouse_click"): #This works smoother instead of the Input.is_mouse_button_pressed() idk why
self.position = get_global_mouse_position()
func _on_Carta_mouse_entered() -> void:
mouse_in = true
func _on_Carta_mouse_exited() -> void:
mouse_in = false
In other words, what I’m trying to achieve is move a node that has an Area2D + CollisionShape2D + TextureRect(Same size as collisionshape) and be able to click and drag the node/card through the screen. It has something to do with the TextureRect for sure but I can’t find what is going on.
Also add debug prints in the code signals and you will found out that they only execute when clicking and holding the mouse, then drag inside the area, and then release the click, which results in a IN OUT print at the same same time.
Screenshot of the code:
Screenshot of the scene: