Enemy directional sprite
This commit is contained in:
parent
464c5ecfd5
commit
da15717c28
20 changed files with 349 additions and 0 deletions
23
base/scripts/enemies/directional_sprite3d.gd
Normal file
23
base/scripts/enemies/directional_sprite3d.gd
Normal file
|
@ -0,0 +1,23 @@
|
|||
@tool
|
||||
extends Sprite3D
|
||||
|
||||
|
||||
@export var rotations : Dictionary[float,Texture2D]
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if Engine.is_editor_hint(): return
|
||||
var camera = get_viewport().get_camera_3d()
|
||||
var rotation_to_camera = global_transform.basis.z.signed_angle_to(camera.global_position,Vector3.UP) + PI
|
||||
var chosen_index = 0
|
||||
for i in rotations.keys():
|
||||
if abs(rotation_to_camera-i) < abs(rotation_to_camera-chosen_index):
|
||||
chosen_index = i
|
||||
texture = rotations[chosen_index]
|
||||
|
||||
@export_tool_button("Generate entries") var generator = entry_generator
|
||||
@export var rotation_count : float = 8
|
||||
|
||||
func entry_generator():
|
||||
rotations.clear()
|
||||
for i in range(rotation_count):
|
||||
rotations[TAU/rotation_count*i] = Texture2D.new()
|
1
base/scripts/enemies/directional_sprite3d.gd.uid
Normal file
1
base/scripts/enemies/directional_sprite3d.gd.uid
Normal file
|
@ -0,0 +1 @@
|
|||
uid://j0w37fjl13ox
|
Loading…
Add table
Add a link
Reference in a new issue