Raycast Hit suddently stopped working
Hi there guys i have been working on an over shoulder view for shooting those last days and i made a raycast to follow the crosshair and it was working perfectly but the camera was center on the head of the character during the zoom phase so i addes few offset and that's the only thing i touched with the camera.
Now suddenly the raycast isn't working anymore even when i tried to undo my last modification with the camera.
so i just can't figure out for the last hours what is going on and why isn't it working anymore.
Here is my code:
void Start () { Destroy (this.gameObject, LifeTime);
Ray rayFromCam = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hitFromCam;
if (Physics.Raycast(rayFromCam, out hitFromCam))
{
if (Input.GetButton("Fire3"))
{
this.gameObject.transform.LookAt(hitFromCam.point);
}
}
}
void Update ()
{
if(!this.gameObject || !this.gameObject.GetComponent<Rigidbody>())
{
return;
}
if (this.gameObject.GetComponent<Rigidbody>())
{
this.gameObject.GetComponent<Rigidbody>().velocity = this.gameObject.transform.forward * Speed;
}
else
{
this.gameObject.transform.position += this.gameObject.transform.forward * Speed * Time.deltaTime;
}
}
Maybe you have allready witnesses that kind of problem .
:)
Comment