i have this script that is supposed to teleport the player to where the mouse is looking by instantiate and destroying itself. it is attached to the player and i know im close but i cant figure out what im doing wrong with raycasthit.point and why im causing so many compiler errors
public bool tpcooldown;
private Transform tpos;
public GameObject playerprefab;
// Use this for initialization
void Start()
{
}
// Update is called once per frame
private void Update()
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
Physics.Raycast(ray, out hit);
}
void teleport()
{
tpcooldown = false;
Instantiate(playerprefab, hit.point, Quaternion.identity );
Destroy(gameObject);
}