20 lines
585 B
GDScript
20 lines
585 B
GDScript
extends Spatial
|
|
class_name TPSController
|
|
|
|
export var character_scene: PackedScene
|
|
onready var character = character_scene.instance()
|
|
var is_in_menu: bool = false
|
|
|
|
func get_target() -> Dictionary:
|
|
var weapon = get_weapon()
|
|
# var ray_from = weapon.global_transform.origin
|
|
var ray_from = cam.global_transform.origin
|
|
var ray_to = cam.global_transform.basis.z * -20000
|
|
var space_state = get_world().direct_space_state
|
|
var result = space_state.intersect_ray(ray_from, ray_to, [self, weapon])
|
|
|
|
if not result:
|
|
return create_empty_collision_dictionnary(ray_to)
|
|
else:
|
|
return result
|