add cursor arrow
This commit is contained in:
@@ -7,6 +7,7 @@ var _side: float
|
||||
@onready var _base: Control = $CursorBase
|
||||
# @onready var _circle: Control = $CursorBase/CursorCircle
|
||||
@onready var _bat: Control = $CursorBase/CursorBat
|
||||
@onready var _arrow: Control = $CursorBase/CursorArrow
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
@@ -25,7 +26,10 @@ func _process(delta: float) -> void:
|
||||
|
||||
var cursor_pos_world := player.attack.global_position + player.aiming.aim_offset
|
||||
var cursor_pos_screen := Referencer.main_camera.unproject_position(cursor_pos_world)
|
||||
_base.position = cursor_pos_screen - _base.size / 2
|
||||
_base.position = (
|
||||
cursor_pos_screen.clamp(Vector2.ZERO, get_viewport().get_visible_rect().size)
|
||||
- _base.size / 2
|
||||
)
|
||||
|
||||
_side = lerpf(
|
||||
_side,
|
||||
@@ -33,13 +37,13 @@ func _process(delta: float) -> void:
|
||||
side_change_speed * delta
|
||||
)
|
||||
|
||||
var rotation_point_world := (
|
||||
cursor_pos_world
|
||||
+ player.aiming.aim_offset.normalized().rotated(Vector3.UP, _side)
|
||||
var aim_offset_normalized := player.aiming.aim_offset.normalized()
|
||||
var bat_rotation_point_screen := Referencer.main_camera.unproject_position(
|
||||
cursor_pos_world + aim_offset_normalized.rotated(Vector3.UP, _side)
|
||||
)
|
||||
var rotation_point_screen := Referencer.main_camera.unproject_position(
|
||||
rotation_point_world
|
||||
var arrow_rotation_point_screen := Referencer.main_camera.unproject_position(
|
||||
cursor_pos_world + aim_offset_normalized
|
||||
)
|
||||
|
||||
var angle := cursor_pos_screen.angle_to_point(rotation_point_screen)
|
||||
_bat.rotation = angle
|
||||
_bat.rotation = cursor_pos_screen.angle_to_point(bat_rotation_point_screen)
|
||||
_arrow.rotation = cursor_pos_screen.angle_to_point(arrow_rotation_point_screen)
|
||||
|
||||
Reference in New Issue
Block a user