本文整理汇总了C#中Duality.Components.Physics.RigidBody.ApplyWorldImpulse方法的典型用法代码示例。如果您正苦于以下问题:C# RigidBody.ApplyWorldImpulse方法的具体用法?C# RigidBody.ApplyWorldImpulse怎么用?C# RigidBody.ApplyWorldImpulse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Duality.Components.Physics.RigidBody
的用法示例。
在下文中一共展示了RigidBody.ApplyWorldImpulse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FireBullet
private void FireBullet(RigidBody body, Transform transform, Vector2 localPos, float localAngle)
{
ShipBlueprint blueprint = this.blueprint.Res;
if (blueprint.BulletType == null) return;
Bullet bullet = blueprint.BulletType.Res.CreateBullet();
Vector2 recoilImpulse;
Vector2 worldPos = transform.GetWorldPoint(localPos);
bullet.Fire(this.owner, body.LinearVelocity, worldPos, transform.Angle + localAngle, out recoilImpulse);
body.ApplyWorldImpulse(recoilImpulse);
Scene.Current.AddObject(bullet.GameObj);
SoundInstance inst = null;
if (Player.AlivePlayers.Count() > 1)
inst = DualityApp.Sound.PlaySound3D(this.owner.WeaponSound, new Vector3(worldPos));
else
inst = DualityApp.Sound.PlaySound(this.owner.WeaponSound);
inst.Volume = MathF.Rnd.NextFloat(0.6f, 1.0f);
inst.Pitch = MathF.Rnd.NextFloat(0.9f, 1.11f);
}