diff --git a/DungeonShooting_Godot/scene/Main.tscn b/DungeonShooting_Godot/scene/Main.tscn
index 6ced005..21417bf 100644
--- a/DungeonShooting_Godot/scene/Main.tscn
+++ b/DungeonShooting_Godot/scene/Main.tscn
@@ -26,7 +26,6 @@
SubViewportContainer = NodePath("ViewCanvas/SubViewportContainer")
SceneRoot = NodePath("ViewCanvas/SubViewportContainer/SubViewport/SceneRoot")
GlobalNodeRoot = NodePath("GlobalNodeRoot")
-Debug = true
[node name="ViewCanvas" type="CanvasLayer" parent="."]
layer = -1
diff --git a/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs b/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs
index 1bdffd3..8d295c0 100644
--- a/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs
+++ b/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs
@@ -1040,6 +1040,19 @@
}
///
+ /// 继承指定物体的运动速率, 该速率可能会有衰减
+ ///
+ public void InheritVelocity(ActivityObject other)
+ {
+ var velocity = other.Velocity;
+ if (velocity != Vector2.Zero)
+ {
+ var force = MoveController.AddConstantForce(velocity * 0.5f, 15);
+ force.EnableResistanceInTheAir = false;
+ }
+ }
+
+ ///
/// 触发投抛动作
///
private void Throw()
diff --git a/DungeonShooting_Godot/src/framework/activity/ExternalForce.cs b/DungeonShooting_Godot/src/framework/activity/ExternalForce.cs
index 53fe1c9..25a62a3 100644
--- a/DungeonShooting_Godot/src/framework/activity/ExternalForce.cs
+++ b/DungeonShooting_Godot/src/framework/activity/ExternalForce.cs
@@ -22,6 +22,11 @@
public float Resistance { get; set; } = 0;
///
+ /// 是否在空中也会受到阻力
+ ///
+ public bool EnableResistanceInTheAir { get; set; } = true;
+
+ ///
/// 当速度到达 0 后是否自动销毁, 默认 true
///
public bool AutoDestroy { get; set; } = true;
diff --git a/DungeonShooting_Godot/src/framework/activity/components/MoveController.cs b/DungeonShooting_Godot/src/framework/activity/components/MoveController.cs
index fa2c05b..b4b8ea4 100644
--- a/DungeonShooting_Godot/src/framework/activity/components/MoveController.cs
+++ b/DungeonShooting_Godot/src/framework/activity/components/MoveController.cs
@@ -85,6 +85,18 @@
force.Resistance = resistance;
return force;
}
+
+ ///
+ /// 快速创建一个外力, 该外力为匿名外力, 当速率变为 0 时自动销毁
+ ///
+ /// 外力速率
+ public ExternalForce AddConstantForce(Vector2 velocity)
+ {
+ var force = AddConstantForce("_anonymity_" + _index++);
+ force.Velocity = velocity;
+ return force;
+ }
+
///
/// 根据名称添加一个外力, 并返回创建的外力的对象, 如果存在这个名称的外力, 移除之前的外力, 当速率变为 0 时不会自动销毁
@@ -253,7 +265,7 @@
);
//力速度衰减
- if (force.Resistance != 0)
+ if (force.Resistance != 0 && (force.EnableResistanceInTheAir || !ActivityInstance.IsThrowing))
{
force.Velocity = force.Velocity.MoveToward(Vector2.Zero, force.Resistance * delta);
}
diff --git a/DungeonShooting_Godot/src/game/item/weapon/Weapon.cs b/DungeonShooting_Godot/src/game/item/weapon/Weapon.cs
index 5ba1cf5..e416aae 100644
--- a/DungeonShooting_Godot/src/game/item/weapon/Weapon.cs
+++ b/DungeonShooting_Godot/src/game/item/weapon/Weapon.cs
@@ -990,6 +990,9 @@
var angle = master.MountPoint.GlobalRotationDegrees;
GlobalRotationDegrees = angle;
+
+ //继承role的移动速度
+ InheritVelocity(master);
var startHeight = 6;
var direction = angle + Utils.RandomRangeInt(-20, 20);
diff --git a/DungeonShooting_Godot/src/game/item/weapon/gun/Gun.cs b/DungeonShooting_Godot/src/game/item/weapon/gun/Gun.cs
index b0a9644..fa902fc 100644
--- a/DungeonShooting_Godot/src/game/item/weapon/gun/Gun.cs
+++ b/DungeonShooting_Godot/src/game/item/weapon/gun/Gun.cs
@@ -106,6 +106,7 @@
var velocity = new Vector2(Utils.RandomRangeInt(20, 60), 0).Rotated(direction * Mathf.Pi / 180);
var rotate = Utils.RandomRangeInt(-720, 720);
var shell = Create(ActivityIdPrefix.Shell + "0001");
+ shell.InheritVelocity(Master);
shell.Throw(startPos, startHeight, verticalSpeed, velocity, rotate);
if (Master == GameApplication.Instance.RoomManager.Player)
diff --git a/DungeonShooting_Godot/src/game/item/weapon/gun/Shotgun.cs b/DungeonShooting_Godot/src/game/item/weapon/gun/Shotgun.cs
index 139496f..4ee5e6e 100644
--- a/DungeonShooting_Godot/src/game/item/weapon/gun/Shotgun.cs
+++ b/DungeonShooting_Godot/src/game/item/weapon/gun/Shotgun.cs
@@ -70,6 +70,7 @@
var velocity = new Vector2(Utils.RandomRangeInt(20, 60), 0).Rotated(direction * Mathf.Pi / 180);
var rotate = Utils.RandomRangeInt(-720, 720);
var shell = Create(ActivityIdPrefix.Shell + "0001");
+ shell.InheritVelocity(Master);
shell.Throw(startPos, startHeight, verticalSpeed, velocity, rotate);
if (Master == GameApplication.Instance.RoomManager.Player)