Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

250
Vistas
Manera eficiente de detectar el tacto excepto en el área del joystick

Estoy usando este joystick y Mirror para trabajar en red.

https://github.com/herbou/Unity_EasyJoystick

Y tengo este script para disparar una bala en el toque del usuario

 public class ShootBullet : NetworkBehaviour { [SerializeField] private GameObject bulletPrefab; private GameObject bullet; // Set via the Inspector in Units/second [SerializeField] private float _moveSpeed = 2f; [SerializeField] private Camera _camera; Vector3 touch_Pos = new Vector3(0, 0, 0); private void Awake() { if (!_camera) _camera = Camera.main; } void Update() { if (Input.touchCount > 0 && this.isLocalPlayer) { if (Input.GetTouch(0).phase == TouchPhase.Began) { var touch = Input.GetTouch(0); touch_Pos = _camera.ScreenToWorldPoint(touch.position); this.CmdShoot(); } } if (bullet != null) { bullet.transform.position = Vector3.MoveTowards(bullet.transform.position, touch_Pos, _moveSpeed * Time.deltaTime); } } [Command] void CmdShoot() { bullet = Instantiate(bulletPrefab, this.transform.position, Quaternion.identity); NetworkServer.Spawn(bullet); } }

Mi problema en este momento es que dispara una bala cuando toco el área del joystick. ¿Cuál es la forma eficiente de excluir input.touch en el área del joystick?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Puede transmitir la posición táctil y verificar el resultado.

 var mousePos = Input.mousePosition; var mouseToRay = _camera.ScreenPointToRay(mousePos); RaycastHit hit; if (Physics.Raycast(mouseToRay, out hit)) { var gameObject = hit.collider.gameObject; //Here You can check the name of your object or the layer or tag var isMouseUnderJoyStick = gameObject.CompareTag("Your_UI_Tag"); }

Y tienes que agregar el componente colisionador a tu JoyStick

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda