#Projectile is being influenced by other forces

1 messages · Page 1 of 1 (latest)

raw sandal
#

Hello, i have a gun with a projectile instantiation. So when the player moves, the instantiated projectile is influenced by the players movement. In the video, when the player is moving right, the projectile hits with the gun collider and you can see the hit FX at that point. When the player is not moving and we shoot the gun, the projectile goes with a forward force as expected.

                Rigidbody projectileRigid = projectile.GetComponentInChildren<Rigidbody>();
                projectileRigid.AddForce(MuzzlePointTransform.forward * ShotForce, ForceMode.VelocityChange);```

(P.S: i tried ``` projectileRigid.AddRelativeForce(Vector3.forward * ShotForce, ForceMode.VelocityChange);```  but the result is the same)

if you are reading this, thank you for your time. Really appreciate it.
feral ridge
#

You can start by going into Project Settings -> Physics -> layermatrix at the bottom and make sure your gun and bullet are on different layers that don't collide with each other.
I also recommend you add a method to your Projectile, like: public void ApplyForce(Vector3 forward, float force){}

That way your Gun script doesn't need to find the rb of your bullet