The raycast from my gun start at the main câmera. But if the angle is too low (if i look to the floor), the raycast hits the player. If i keep shooting at the floor, i die (whatheheck). I was previously raycasting from an empty GameObject in front of the camera, and was working just fine.
My script just in case:
if (Physics.Raycast(Camera.main.transform.position, Camera.main.transform.forward, out ray, range)) {
life = ray.transform.GetComponent<life>();
if (life != null) {
life.TakeDamage(damage);
}
rigidbuddy = raio.transform.GetComponent<Rigidbody>();
if (rigidbuddy != null) {
rigidbuddy.AddForce(-transform.forward * 40 * danodaarma);
}
}
Usual everyday stuff. I don’t know why such a bug happens.