Yep, that did it, I had a boolean activate and deactivate when the mouse entered the UI element and that stopped the raycasting from happening in the main click if statement, that's all working now, signals are wonderful lol, thanks guys, that gave me the idea on how to fix it.
extends Spatial
onready var playerCameraGroup = get_tree().get_nodes_in_group("PlayerCamera")
onready var playerCamera = playerCameraGroup[0]
var mouseInteractionEnabled = false
var rayOrigin = Vector3()
var rayEnd = Vector3()
var previousSelection
var currentSelection
func _physics_process(_delta):
var spaceState = get_world().direct_space_state
var mousePosition = get_viewport().get_mouse_position()
rayOrigin = playerCamera.project_ray_origin(mousePosition)
rayEnd = rayOrigin + playerCamera.project_ray_normal(mousePosition) * 3000
var intersection = spaceState.intersect_ray(rayOrigin, rayEnd)
if Input.is_action_just_pressed("RightClick"):
pass
if Input.is_action_just_pressed("LeftClick") and mouseInteractionEnabled == true:
if not previousSelection == null:
previousSelection.visible = false
if intersection.collider.is_in_group("PlayerArmy"):
currentSelection = intersection.collider.get_child(0)
currentSelection.visible = true
previousSelection = currentSelection
print ("Player Army Selected")
if intersection.collider.is_in_group("PlayerTown"):
currentSelection = intersection.collider.get_child(0)
currentSelection.visible = true
previousSelection = currentSelection
print ("Player Town Selected")
if intersection.collider.is_in_group("NeutralTown"):
currentSelection = intersection.collider.get_child(0)
currentSelection.visible = true
previousSelection = currentSelection
print ("Neutral Town Selected")
if intersection.collider.is_in_group("EnemyTown"):
currentSelection = intersection.collider.get_child(0)
currentSelection.visible = true
previousSelection = currentSelection
print ("Enemy Town Selected")
if intersection.collider.is_in_group("Floor"):
if not previousSelection == null:
previousSelection.visible = false
if not currentSelection == null:
currentSelection.visible = false
print ("Floor Selected")
func _on_Button_mouse_entered():
mouseInteractionEnabled = false
func _on_Button_mouse_exited():
mouseInteractionEnabled = true