Fixed RangedWeapon launching projectiles in an incorrect rotation
This commit is contained in:
@@ -89,17 +89,20 @@ namespace Barotrauma.Items.Components
|
|||||||
//so that the player can't shoot himself
|
//so that the player can't shoot himself
|
||||||
Projectile projectileComponent= projectile.GetComponent<Projectile>();
|
Projectile projectileComponent= projectile.GetComponent<Projectile>();
|
||||||
if (projectileComponent == null) continue;
|
if (projectileComponent == null) continue;
|
||||||
|
|
||||||
|
float rotation = ((item.body.Dir == 1.0f) ? item.body.Rotation : item.body.Rotation - MathHelper.Pi) + Rand.Range(-degreeOfFailure, degreeOfFailure);
|
||||||
|
|
||||||
projectile.body.ResetDynamics();
|
projectile.body.ResetDynamics();
|
||||||
projectile.SetTransform(TransformedBarrelPos,
|
projectile.SetTransform(TransformedBarrelPos, rotation);
|
||||||
((item.body.Dir == 1.0f) ? item.body.Rotation : item.body.Rotation - MathHelper.Pi)
|
|
||||||
+ Rand.Range(-degreeOfFailure, degreeOfFailure));
|
|
||||||
|
|
||||||
projectile.Use(deltaTime);
|
projectile.Use(deltaTime);
|
||||||
projectileComponent.User = character;
|
projectileComponent.User = character;
|
||||||
|
|
||||||
projectile.body.ApplyTorque(projectile.body.Mass * degreeOfFailure * Rand.Range(-10.0f, 10.0f));
|
projectile.body.ApplyTorque(projectile.body.Mass * degreeOfFailure * Rand.Range(-10.0f, 10.0f));
|
||||||
|
|
||||||
|
//set the rotation of the projectile again because dropping the projectile resets the rotation
|
||||||
|
projectile.SetTransform(projectile.SimPosition, rotation);
|
||||||
|
|
||||||
//recoil
|
//recoil
|
||||||
item.body.ApplyLinearImpulse(
|
item.body.ApplyLinearImpulse(
|
||||||
new Vector2((float)Math.Cos(projectile.body.Rotation), (float)Math.Sin(projectile.body.Rotation)) * item.body.Mass * -50.0f);
|
new Vector2((float)Math.Cos(projectile.body.Rotation), (float)Math.Sin(projectile.body.Rotation)) * item.body.Mass * -50.0f);
|
||||||
|
|||||||
Reference in New Issue
Block a user