I'm trying to make my character shoot along linecast. Linecast starts from bulletspawnpoint and ends at point where mouse is pointing. This is third person shooter. Here is my code:
void Update()
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit HitPoint;
RaycastHit HitPointMouse;
Physics.Raycast(ray, out HitPoint);
Physics.Linecast(GameObject.Find("Player").transform.position, HitPoint.point, out HitPointMouse);
Debug.DrawLine(GameObject.Find("Player").transform.position, HitPoint.point, Color.yellow);
if(Input.GetButtonDown("Fire1"))
{
Instantiate(Bullet, GameObject.Find("BulletSpawnPoint").transform.position, Quaternion.identity);
Bullet.rigidbody.AddForce(<DirectionOfRayHere> * 1000);
}
}