Upload files to "/"
This commit is contained in:
parent
5237550eb3
commit
e1f512e30b
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,91 @@
|
||||||
|
extends Node3D
|
||||||
|
|
||||||
|
|
||||||
|
@export var camera: Camera3D
|
||||||
|
@export var drone: PackedScene
|
||||||
|
@export var navreg: NavigationRegion3D
|
||||||
|
var targetLoc= Vector3()
|
||||||
|
var drones = Array()
|
||||||
|
var curDrone = 0
|
||||||
|
var ignoreNext = false
|
||||||
|
var clickPos
|
||||||
|
@export var indivRadius = 1
|
||||||
|
var spawnpoints = Array()
|
||||||
|
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready():
|
||||||
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
func _process(delta):
|
||||||
|
var lol = 1
|
||||||
|
if Input.is_action_just_pressed("right_click"):
|
||||||
|
var newDrone = drone.instantiate()
|
||||||
|
self.add_child(newDrone)
|
||||||
|
targetLoc = _click_intersect()
|
||||||
|
drones.append(newDrone)
|
||||||
|
newDrone.position = targetLoc
|
||||||
|
newDrone.cam = camera
|
||||||
|
newDrone.navres = navreg
|
||||||
|
if Input.is_action_just_pressed("left_click") && (drones.size()>0):
|
||||||
|
for d in drones:
|
||||||
|
d.canMove = false
|
||||||
|
_click_intersect()
|
||||||
|
drones[0]._do_path(spawnpoints[0])
|
||||||
|
#newDrone.canMove = true
|
||||||
|
|
||||||
|
func _click_intersect():
|
||||||
|
var space_state = get_world_3d().direct_space_state
|
||||||
|
var mouse_position = get_viewport().get_mouse_position()
|
||||||
|
var rayOrigin = camera.project_ray_origin(mouse_position)
|
||||||
|
var rayEnd = rayOrigin + camera.project_ray_normal(mouse_position)*20000
|
||||||
|
var query = PhysicsRayQueryParameters3D.create(rayOrigin,rayEnd)
|
||||||
|
var intersection = space_state.intersect_ray(query)
|
||||||
|
|
||||||
|
|
||||||
|
if intersection.is_empty():
|
||||||
|
intersection = get_global_position()
|
||||||
|
print("nothing found")
|
||||||
|
else:
|
||||||
|
print (get_name())
|
||||||
|
|
||||||
|
clickPos = intersection.position
|
||||||
|
_circle_points(clickPos)
|
||||||
|
return clickPos
|
||||||
|
|
||||||
|
func _circle_points(center:Vector3):
|
||||||
|
spawnpoints.clear()
|
||||||
|
var count = drones.size()
|
||||||
|
var radius = 0
|
||||||
|
var angle = 1
|
||||||
|
if(count == 0): return
|
||||||
|
elif(count == 1): spawnpoints.append(center)
|
||||||
|
elif (count>2):
|
||||||
|
angle = _deg_rad(360/count)
|
||||||
|
radius = indivRadius/sin(angle)
|
||||||
|
for i in range(count):
|
||||||
|
spawnpoints.append(center + (Vector3.FORWARD*radius*1.5).rotated(Vector3.UP, angle*i))
|
||||||
|
|
||||||
|
|
||||||
|
func _deg_rad(f:float):
|
||||||
|
return(f*0.0174533)
|
||||||
|
|
||||||
|
func _on_navigation_region_3d_bake_finished():
|
||||||
|
if(ignoreNext == false):
|
||||||
|
curDrone = curDrone+1
|
||||||
|
if(curDrone<drones.size()):
|
||||||
|
await get_tree().create_timer(0.05).timeout
|
||||||
|
drones[curDrone]._do_path(spawnpoints[curDrone])
|
||||||
|
|
||||||
|
else:
|
||||||
|
for d in drones:
|
||||||
|
d.canMove = true
|
||||||
|
d.cleanUp()
|
||||||
|
await get_tree().create_timer(0.05).timeout
|
||||||
|
navreg.bake_navigation_mesh()
|
||||||
|
curDrone = 0
|
||||||
|
ignoreNext = true
|
||||||
|
else:
|
||||||
|
ignoreNext = false
|
|
@ -0,0 +1,21 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="wavefront_obj"
|
||||||
|
importer_version=1
|
||||||
|
type="Mesh"
|
||||||
|
uid="uid://c63wm5ikugi4n"
|
||||||
|
path="res://.godot/imported/dmesho.obj-ac407bcb96360c8b645c94a00bb1d0fb.mesh"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
files=["res://.godot/imported/dmesho.obj-ac407bcb96360c8b645c94a00bb1d0fb.mesh"]
|
||||||
|
|
||||||
|
source_file="res://dmesho.obj"
|
||||||
|
dest_files=["res://.godot/imported/dmesho.obj-ac407bcb96360c8b645c94a00bb1d0fb.mesh", "res://.godot/imported/dmesho.obj-ac407bcb96360c8b645c94a00bb1d0fb.mesh"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
generate_tangents=true
|
||||||
|
scale_mesh=Vector3(1, 1, 1)
|
||||||
|
offset_mesh=Vector3(0, 0, 0)
|
||||||
|
optimize_mesh=true
|
|
@ -0,0 +1,7 @@
|
||||||
|
[gd_scene load_steps=2 format=3 uid="uid://b3smokxlmnsr3"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://bnlq6yuitbyog" path="res://spiridrone.glb" id="1_3f7ol"]
|
||||||
|
|
||||||
|
[node name="drone" type="Node3D"]
|
||||||
|
|
||||||
|
[node name="spiridrone" parent="." instance=ExtResource("1_3f7ol")]
|
Loading…
Reference in New Issue