#pragma strict
private var lineTransform : Vector3;
private var startTransform : Vector3;
function Start () {
lineTransform = transform.position;
startTransform = transform.position;
}
function Update () {
var hit : RaycastHit;
var ray : Ray = Camera.main.ScreenPointToRay(Vector3(Screen.width*0.5, Screen.height*0.5, 0));
if (Input.GetKeyDown(KeyCode.Mouse0)) {
if (Physics.Raycast(ray, hit, 100)) {
Debug.DrawRay(startTransform, lineTransform, Color.red);
}
}
}
I did what you said, but for some reason the when i shot it just shots where the camera started. Even though the camera follows the ball the shot comes from the cameras startpoint in the game?
I did the tag first, but for some reason whenever i shot the “red line” only appears, at the cameras startpoint, when i start to roll around the camera follows, but the “Red line” keeps coming from the same position
I also did the GetComponent(Camera), but when i click the mouse the i cant move the ball or use any controls