Ejemplo n.º 1
0
 // Update is called once per frame
 void Update()
 {
     if (playerController.InsideVehicle())
     {
         if (Input.GetKeyDown(KeyCode.E))
         {
             playerController.ExitVehicle(transform.position + playerOffset);
         }
         else
         {
             if (Input.GetMouseButton(0))
             {
                 Ray        ray = camera.ScreenPointToRay(Input.mousePosition);
                 RaycastHit hit;
                 int        layerMask = groundLayer;
                 if (Physics.Raycast(ray, out hit, Mathf.Infinity, layerMask))
                 {
                     agent.SetDestination(hit.point);
                     marker.transform.position = new Vector3(hit.point.x, 0, hit.point.z);
                     marker.SetActive(true);
                 }
             }
         }
     }
     else if (!playerController.InsideVehicle())
     {
         float distance = Vector3.Distance(player.transform.position, transform.position);
         if (distance <= maxInteractionDist)
         {
             playerController.closeToVehicle = true;
         }
         else
         {
             playerController.closeToVehicle = false;
         }
     }
 }