29 lines
No EOL
851 B
GDScript
29 lines
No EOL
851 B
GDScript
extends Spatial
|
|
|
|
signal card_selected()
|
|
signal card_unselected()
|
|
|
|
var lifted := false
|
|
|
|
onready var animation := $Border/AnimationPlayer
|
|
|
|
func _mouse_hover():
|
|
emit_signal("card_selected")
|
|
|
|
func _mouse_blur():
|
|
emit_signal("card_unselected")
|
|
|
|
func _input_event(camera, event, click_position, click_normal, shape_idx):
|
|
if event is InputEventMouseButton and event.button_index == BUTTON_LEFT:
|
|
if event.pressed:
|
|
lifted = true
|
|
animation.play("lift")
|
|
else:
|
|
lifted = false
|
|
animation.play_backwards("lift")
|
|
if lifted and event is InputEventMouseMotion:
|
|
var origin: Vector3 = camera.project_ray_origin(event.position)
|
|
var direction: Vector3 = camera.project_ray_normal(event.position)
|
|
var denom := Vector3.UP.dot(direction)
|
|
var t: float = (-camera.transform.origin).dot(Vector3.UP) / denom;
|
|
transform.origin = origin + direction * t |