Hi,
I’ve been making a simple topdown shooter. It works fine, when I shoot I move slower and face the direction i’m shooting, but when I try to hit a target that is standing a bit higher on the Y axis, Everything goes wrong. The linerenderer focuses perfectly on the object at the beginning, but when I start moving the line itself moves away from the object or seems to even be above it for some reason?
Here is the code:
Floorhit is already called in the Awake function
IEnumerator RenderTracer(Vector3 hitPoint){
Ray camRay = Camera.main.ScreenPointToRay (Input.mousePosition);
RaycastHit floorHit;
float camRayLength = 100f;
if (Physics.Raycast (camRay, out floorHit, camRayLength, floorMask))
{
hitPoint = floorHit.point;
}
tracer.enabled = true;
tracer.SetPosition(1, spawnBullet.position);
tracer.SetPosition(0, spawnBullet.position + hitPoint);
yield return null;
tracer.enabled = false;
}
Does it have something to do with the camRayLength? I can’t seem to get the right thing to do here.