-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
258 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[gd_scene load_steps=3 format=3 uid="uid://cdwd5g0p36bei"] | ||
|
||
[ext_resource type="PackedScene" uid="uid://infrrx4bca6i" path="res://targets/sliding_target.tscn" id="1_5kdus"] | ||
[ext_resource type="PackedScene" uid="uid://cjm4ncojk7pki" path="res://vehicles/evading_vehicle.tscn" id="2_4vqy5"] | ||
|
||
[node name="evade" type="Node2D"] | ||
|
||
[node name="sliding_target" parent="." instance=ExtResource("1_5kdus")] | ||
linear_damp_mode = 1 | ||
|
||
[node name="evading_vehicle" parent="." node_paths=PackedStringArray("target") instance=ExtResource("2_4vqy5")] | ||
target = NodePath("../sliding_target") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[gd_scene load_steps=3 format=3 uid="uid://d0aqshen3pu4s"] | ||
|
||
[ext_resource type="PackedScene" uid="uid://b3ej2trb8osvg" path="res://targets/click_target.tscn" id="2_rtm3k"] | ||
[ext_resource type="PackedScene" uid="uid://do44pgjw83f0v" path="res://vehicles/fleeing_vehicle.tscn" id="3_pjm6k"] | ||
|
||
[node name="flee" type="Node2D"] | ||
|
||
[node name="click_target" parent="." instance=ExtResource("2_rtm3k")] | ||
|
||
[node name="fleeing_vehicle" parent="." node_paths=PackedStringArray("target") instance=ExtResource("3_pjm6k")] | ||
target = NodePath("../click_target") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[gd_scene load_steps=4 format=3 uid="uid://chvgjsd1am5yp"] | ||
|
||
[ext_resource type="PackedScene" uid="uid://4jey0e27fxnu" path="res://targets/fleeing_target.tscn" id="1_gabhm"] | ||
[ext_resource type="PackedScene" uid="uid://ba65gavov6hfm" path="res://vehicles/pursuing_vehicle.tscn" id="2_k3inf"] | ||
[ext_resource type="Script" path="res://targets/fleeing_target.gd" id="2_p51fv"] | ||
|
||
[node name="funsies" type="Node2D"] | ||
|
||
[node name="fleeing_target" parent="." node_paths=PackedStringArray("target") instance=ExtResource("1_gabhm")] | ||
position = Vector2(426, 235) | ||
script = ExtResource("2_p51fv") | ||
target = NodePath("../pursuing_vehicle") | ||
|
||
[node name="pursuing_vehicle" parent="." node_paths=PackedStringArray("target") instance=ExtResource("2_k3inf")] | ||
position = Vector2(332, 142) | ||
target = NodePath("../fleeing_target") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[gd_scene load_steps=3 format=3 uid="uid://d3250ocpee3fw"] | ||
|
||
[ext_resource type="PackedScene" uid="uid://infrrx4bca6i" path="res://targets/sliding_target.tscn" id="1_2jp1h"] | ||
[ext_resource type="PackedScene" uid="uid://bsxx8mmxh8a5u" path="res://vehicles/offset_pursuing_vehicle.tscn" id="2_yip7c"] | ||
|
||
[node name="offset_pursuit" type="Node2D"] | ||
|
||
[node name="sliding_target" parent="." instance=ExtResource("1_2jp1h")] | ||
position = Vector2(386, 215) | ||
linear_damp_mode = 1 | ||
|
||
[node name="offset_pursuing_vehicle" parent="." node_paths=PackedStringArray("target") instance=ExtResource("2_yip7c")] | ||
target = NodePath("../sliding_target") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[gd_scene load_steps=3 format=3 uid="uid://caqiud54bwepk"] | ||
|
||
[ext_resource type="PackedScene" uid="uid://infrrx4bca6i" path="res://targets/sliding_target.tscn" id="1_2d4cr"] | ||
[ext_resource type="PackedScene" uid="uid://ba65gavov6hfm" path="res://vehicles/pursuing_vehicle.tscn" id="2_ebshu"] | ||
|
||
[node name="pursuit" type="Node2D"] | ||
|
||
[node name="sliding_target" parent="." instance=ExtResource("1_2d4cr")] | ||
position = Vector2(305, 136) | ||
mass = 0.01 | ||
linear_velocity = Vector2(250, 20) | ||
linear_damp_mode = 1 | ||
|
||
[node name="pursuing_vehicle" parent="." node_paths=PackedStringArray("target") instance=ExtResource("2_ebshu")] | ||
position = Vector2(116, 128) | ||
target = NodePath("../sliding_target") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[gd_scene load_steps=3 format=3 uid="uid://cx31jewsu8sok"] | ||
|
||
[ext_resource type="PackedScene" uid="uid://b3ej2trb8osvg" path="res://targets/click_target.tscn" id="1_1ruvh"] | ||
[ext_resource type="PackedScene" uid="uid://q84qhepieh22" path="res://vehicles/seeking_vehicle.tscn" id="2_ws6kx"] | ||
|
||
[node name="seek" type="Node2D"] | ||
|
||
[node name="click_target" parent="." instance=ExtResource("1_1ruvh")] | ||
|
||
[node name="seeking_vehicle" parent="." node_paths=PackedStringArray("target") instance=ExtResource("2_ws6kx")] | ||
target = NodePath("../click_target") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
extends "res://targets/target.gd" | ||
|
||
func _process(delta): | ||
if Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT): | ||
position = get_global_mouse_position() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[gd_scene load_steps=2 format=3 uid="uid://b3ej2trb8osvg"] | ||
|
||
[ext_resource type="Script" path="res://targets/click_target.gd" id="1_rmt10"] | ||
|
||
[node name="click_target" type="RigidBody2D"] | ||
gravity_scale = 0.0 | ||
script = ExtResource("1_rmt10") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
extends "res://vehicles/fleeing_vehicle.gd" | ||
|
||
|
||
func _draw(): | ||
draw_circle(Vector2.ZERO, 10, Color.RED) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[gd_scene load_steps=2 format=3 uid="uid://4jey0e27fxnu"] | ||
|
||
[ext_resource type="PackedScene" uid="uid://butgg65inr3bj" path="res://targets/target.tscn" id="1_k7m0x"] | ||
|
||
[node name="fleeing_target" instance=ExtResource("1_k7m0x")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
extends "res://targets/target.gd" | ||
|
||
func _process(delta): | ||
position = position.posmodv(screen) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[gd_scene load_steps=3 format=3 uid="uid://infrrx4bca6i"] | ||
|
||
[ext_resource type="PackedScene" uid="uid://butgg65inr3bj" path="res://targets/target.tscn" id="1_8olrm"] | ||
[ext_resource type="Script" path="res://targets/sliding_target.gd" id="2_ulyfq"] | ||
|
||
[node name="sliding_target" instance=ExtResource("1_8olrm")] | ||
linear_velocity = Vector2(50, 0) | ||
script = ExtResource("2_ulyfq") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
extends RigidBody2D | ||
extends "res://vehicles/vehicle.gd" | ||
|
||
func _draw(): | ||
draw_circle(Vector2.ZERO, 10, Color.RED) | ||
|
||
func _process(delta): | ||
if Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT): | ||
position = get_global_mouse_position() | ||
position = get_global_mouse_position() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
extends "res://vehicles/vehicle.gd" | ||
|
||
|
||
func _draw(): | ||
var p := future_target_position() * get_global_transform_with_canvas() | ||
draw_circle(p, 3, Color.GREEN) | ||
super._draw() | ||
|
||
func steer(target: RigidBody2D) -> Vector2: | ||
var desired_velocity: Vector2 = (position - future_target_position()).normalized() * max_speed | ||
var steering = desired_velocity - linear_velocity | ||
return steering | ||
|
||
func future_target_position() -> Vector2: | ||
# future_time_look_ahead = distance / speed | ||
var look_ahead: float | ||
if !linear_velocity.is_zero_approx(): | ||
look_ahead = (position.distance_to(target.position)) / linear_velocity.length() | ||
|
||
# 20 is a constant, a turning parameter as Chris Reynolds puts it. | ||
return target.position + (target.linear_velocity * look_ahead) / 20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[gd_scene load_steps=3 format=3 uid="uid://cjm4ncojk7pki"] | ||
|
||
[ext_resource type="PackedScene" uid="uid://cxi54gpin4hg2" path="res://vehicles/vehicle.tscn" id="1_kdgb3"] | ||
[ext_resource type="Script" path="res://vehicles/evading_vehicle.gd" id="2_arvux"] | ||
|
||
[node name="evading_vehicle" instance=ExtResource("1_kdgb3")] | ||
script = ExtResource("2_arvux") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
extends "res://vehicles/vehicle.gd" | ||
|
||
func steer(target: RigidBody2D) -> Vector2: | ||
var desired_velocity: Vector2 = (position - target.position).normalized() * max_speed | ||
var steering = desired_velocity - linear_velocity | ||
return steering |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[gd_scene load_steps=3 format=3 uid="uid://do44pgjw83f0v"] | ||
|
||
[ext_resource type="PackedScene" uid="uid://cxi54gpin4hg2" path="res://vehicles/vehicle.tscn" id="1_e646x"] | ||
[ext_resource type="Script" path="res://vehicles/fleeing_vehicle.gd" id="2_6rvj6"] | ||
|
||
[node name="fleeing_vehicle" instance=ExtResource("1_e646x")] | ||
script = ExtResource("2_6rvj6") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
extends "res://vehicles/vehicle.gd" | ||
|
||
func _draw(): | ||
# global space to local space transformation | ||
var p := future_target_position() * get_global_transform_with_canvas() | ||
draw_circle(p, 3, Color.GREEN) | ||
draw_line(Vector2.ZERO, linear_velocity.orthogonal().normalized()*-20, Color.YELLOW) | ||
super._draw() | ||
|
||
func steer(target: RigidBody2D) -> Vector2: | ||
var desired_velocity: Vector2 = (future_target_position() - position).normalized() * max_speed | ||
var steering = desired_velocity - linear_velocity | ||
return steering | ||
|
||
func future_target_position() -> Vector2: | ||
const radius := 10 | ||
|
||
# project to local coordinate space | ||
var local_target_position := target.position * get_global_transform_with_canvas() | ||
var local_projection := local_target_position.project(linear_velocity.orthogonal()) | ||
local_projection = local_projection.normalized() * -1 * radius | ||
print("local projection", local_projection) | ||
|
||
var new_target_position := local_target_position + local_projection | ||
var new_global_target_position := new_target_position * get_global_transform_with_canvas().inverse() | ||
|
||
if (new_global_target_position.is_finite()): | ||
return new_global_target_position | ||
return target.position |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[gd_scene load_steps=3 format=3 uid="uid://bsxx8mmxh8a5u"] | ||
|
||
[ext_resource type="PackedScene" uid="uid://cxi54gpin4hg2" path="res://vehicles/vehicle.tscn" id="1_3b8ps"] | ||
[ext_resource type="Script" path="res://vehicles/offset_pursuing_vehicle.gd" id="2_mrd1s"] | ||
|
||
[node name="offset_pursuing_vehicle" instance=ExtResource("1_3b8ps")] | ||
script = ExtResource("2_mrd1s") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
extends "res://vehicles/vehicle.gd" | ||
|
||
func _draw(): | ||
var p := future_target_position() * get_global_transform_with_canvas() | ||
draw_circle(p, 3, Color.GREEN) | ||
super._draw() | ||
|
||
func steer(target: RigidBody2D) -> Vector2: | ||
var desired_velocity: Vector2 = (future_target_position() - position).normalized() * max_speed | ||
var steering = desired_velocity - linear_velocity | ||
return steering | ||
|
||
func future_target_position() -> Vector2: | ||
# future_time_look_ahead = distance / speed | ||
var look_ahead: float | ||
if !linear_velocity.is_zero_approx(): | ||
look_ahead = (position.distance_to(target.position)) / linear_velocity.length() | ||
|
||
# 20 is a constant, a turning parameter as Chris Reynolds puts it. | ||
return target.position + (target.linear_velocity * look_ahead) / 20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[gd_scene load_steps=3 format=3 uid="uid://ba65gavov6hfm"] | ||
|
||
[ext_resource type="PackedScene" uid="uid://cxi54gpin4hg2" path="res://vehicles/vehicle.tscn" id="1_orrlx"] | ||
[ext_resource type="Script" path="res://vehicles/pursuing_vehicle.gd" id="2_ghjxm"] | ||
|
||
[node name="pursuing_vehicle" instance=ExtResource("1_orrlx")] | ||
script = ExtResource("2_ghjxm") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
extends "res://vehicles/vehicle.gd" | ||
|
||
func steer(target: RigidBody2D) -> Vector2: | ||
var desired_velocity: Vector2 = (target.position - position).normalized() * max_speed | ||
var steering = desired_velocity - linear_velocity | ||
return steering |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[gd_scene load_steps=3 format=3 uid="uid://q84qhepieh22"] | ||
|
||
[ext_resource type="PackedScene" uid="uid://cxi54gpin4hg2" path="res://vehicles/vehicle.tscn" id="1_n8m25"] | ||
[ext_resource type="Script" path="res://vehicles/seeking_vehicle.gd" id="2_hdxun"] | ||
|
||
[node name="seeking_vehicle" instance=ExtResource("1_n8m25")] | ||
mass = 1.0 | ||
script = ExtResource("2_hdxun") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.