steering_behaviors 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md
CHANGED
@@ -17,10 +17,9 @@ class SteeringBehaviors::Align
|
|
17
17
|
# -
|
18
18
|
#
|
19
19
|
def self.steer(hunter_kinematic, quarry_kinematic)
|
20
|
-
|
20
|
+
desired_velocity = quarry_kinematic.heading_vec * hunter_kinematic.velocity_vec.length
|
21
21
|
|
22
|
-
|
23
|
-
target_local.rotate!(hunter_kinematic.heading_vec.radians)
|
22
|
+
return desired_velocity - hunter_kinematic.velocity_vec
|
24
23
|
end
|
25
24
|
|
26
25
|
end
|
@@ -27,7 +27,9 @@ class SteeringBehaviors::Broadside
|
|
27
27
|
|
28
28
|
best_hdg_vec = (da < db ? option_a : option_b)
|
29
29
|
|
30
|
-
desired_velocity = best_hdg_vec * hunter_kinematic.velocity_vec.length
|
30
|
+
desired_velocity = best_hdg_vec.normalize * hunter_kinematic.velocity_vec.length
|
31
|
+
|
32
|
+
return desired_velocity - hunter_kinematic.velocity_vec
|
31
33
|
end
|
32
34
|
|
33
35
|
end
|
@@ -17,12 +17,9 @@ class SteeringBehaviors::Match
|
|
17
17
|
# - the steering force
|
18
18
|
#
|
19
19
|
def self.steer(hunter_kinematic, quarry_kinematic)
|
20
|
-
|
20
|
+
desired_velocity = quarry_kinematic.heading_vec * quarry_kinematic.velocity_vec.length
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
target_local = SteeringBehaviors::Vector.new(course_diff * quarry_kinematic.speed, speed_diff)
|
25
|
-
target_local.rotate!(hunter_kinematic.heading_vec.radians)
|
22
|
+
return desired_velocity - hunter_kinematic.velocity_vec
|
26
23
|
end
|
27
24
|
|
28
25
|
end
|
@@ -16,9 +16,8 @@ class SteeringBehaviors::Steering
|
|
16
16
|
# - +kinematic+ -> the kinematic thing
|
17
17
|
# - +steering_force+ -> force vector supplied by a steering behavior
|
18
18
|
# - +delta+ -> time delta (in seconds) used for scaling the result
|
19
|
-
# - +accelerative+ -> whether you want the steering to change the thing's velocity (default true)
|
20
19
|
#
|
21
|
-
def self.feel_the_force(kinematic, steering_force, delta
|
20
|
+
def self.feel_the_force(kinematic, steering_force, delta)
|
22
21
|
acceleration = steering_force / kinematic.mass
|
23
22
|
|
24
23
|
# Compute the new, proposed velocity vector.
|