Why does my shoot script break when I build the game
So my game has the player shoot arrows from a bow. My problem is that the higher up I look the farther off course the ray hit point is. Then the lower I look from straight ahead the farther offset the arrow becomes. EX: if from straight-ahead I look up the arrow shoots extra far up. I know my problem has something to do with the target point because I have a line renderer that draws a line from the position of the bow to the target position, and the target position is always way off (only in the build). The ray script is as follows: *
private Vector3 ShootRay()
{
//find exact hit position
Ray ray = FPScam.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0));
RaycastHit hit;
//check if ray hits something
if (Physics.Raycast(FPScam.transform.position, FPScam.transform.forward, out hit, ~playerLayer))
{
targetPoint = hit.point;
}
else targetPoint = ray.GetPoint(75);//shooting away from player to a distance of 25;
DebugTextBox.SetText("PlayerTransform.positiom = "+ GameObject.Find("Player").transform.position + "Ray" +(ray)+ " TargetPoint" + (targetPoint) + " hit" + (hit));
//calculate direction from attack point to target point
return targetPoint;
}
Any help or advice would be amazing! If you need any more information about the problem let me know and I can get it to you.
Your answer
Follow this Question
Related Questions
What BuildTargetGroup option is the right for a linux build? 1 Answer
there is no build fail but editor script doesn't work in build 1 Answer
Variations of MouseScrollWheel input not detected in build ??? 0 Answers
Shooting at mouse position with a slight camera rotation 0 Answers
Extremely Low FPS in Editor, smooth in Build. how to fix? 3 Answers