diff options
Diffstat (limited to 'godot/backup_stuff/Sailor.gd')
| -rw-r--r-- | godot/backup_stuff/Sailor.gd | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/godot/backup_stuff/Sailor.gd b/godot/backup_stuff/Sailor.gd new file mode 100644 index 0000000..24b93f9 --- /dev/null +++ b/godot/backup_stuff/Sailor.gd @@ -0,0 +1,43 @@ +extends KinematicBody + + +# Declare member variables here. Examples: +# var a = 2 +# var b = "text" +export(NodePath) var parent_vehicle = null +#onready var nav_agent : NavigationAgent = get_node("NavigationAgent") +var parent_vehicle_nav = null + +var destination = Vector3.ZERO +var closest_point = Vector3.ZERO +var direction = Vector3.ZERO +var path = null +var pathfinding = false + +const speed = 5 +var velocity = Vector3.ZERO + + +# Called when the node enters the scene tree for the first time. +func _ready(): + if parent_vehicle != null: + parent_vehicle = get_node(parent_vehicle) + parent_vehicle_nav = parent_vehicle.get_node("Navigation") + #nav_agent.set_navigation(parent_vehicle_nav) + +func update_destination(new_dest): + pass#nav_agent.set_target_location(new_dest) + +func move(delta): + var target = Vector3.ZERO#nav_agent.get_next_location() + var direction : Vector3 = (target - global_transform.origin).normalized() * speed + velocity.y -= 9.8*delta + velocity.x = direction.normalized().x*speed + velocity.z = direction.normalized().z*speed + #nav_agent.set_velocity(Vector3(velocity.x,0,velocity.z)) + velocity = move_and_slide(velocity, Vector3.UP, true, 4, 0.785, false) + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _physics_process(delta): + move(delta) |
