When player shoot, the bullet fly to the center of the screen. But if player stay too close to some object, then bullet hits it not in the center, because it flies from the gun on the right side of the screen. How can I fix this?
public Rigidbody projectile; public int speed = 50; public Transform startBulletPosition; void Update() { if (Input.GetButtonDown("Fire1")) { Rigidbody clone; clone = Instantiate(projectile, startBulletPosition.position, transform.rotation) as Rigidbody; var centre = new Vector3(0.5f, 0.5f, 0f); var ray = Camera.main.ViewportPointToRay(centre); clone.velocity = ray.direction * speed; } } 
