Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

270
Views
Los ejes MouseX y MouseY no funcionan Unity 2020.1.0f1

He buscado en Internet y todas las preguntas dicen que esto está solucionado, pero estoy experimentando algunos problemas. Este es mi código:

 private Vector3 startingPos; [HideInInspector] public bool empty; private bool hovered; private bool waitingForSeconds; private float timeSinceLastUpdate; private float scale = 1000f; [HideInInspector] public GameObject item; [HideInInspector] public Texture itemIcon; private GameObject player; private WeaponManager wm; private Inventory inventory; private GameObject[] craftable; public GameObject slotHolder; private Transform[] slots; private void Update() { float mouseX = Input.GetAxis("Mouse X") * scale * Time.deltaTime; float mouseY = Input.GetAxis("Mouse Y") * scale * Time.deltaTime; print(mouseX + " " + mouseY); if (item) { empty = false; itemIcon = item.GetComponent<Item>().icon; } else { empty = true; itemIcon = null; } this.GetComponent<RawImage>().texture = itemIcon; if (waitingForSeconds) timeSinceLastUpdate += Time.deltaTime; else timeSinceLastUpdate = 0f; if (timeSinceLastUpdate > 1f && item) transform.position = new Vector2(mouseX, mouseY); } public void OnPointerDown(PointerEventData eventData) { if (hovered) waitingForSeconds = true; } public void OnPointerUp(PointerEventData eventData) { waitingForSeconds = false; if (hovered) { transform.position = startingPos; UseItem(); } else { foreach (GameObject craftableItemSlot in craftable) { if (craftableItemSlot.GetComponent<CraftableItem>().hovered) { if (craftableItemSlot.GetComponent<RawImage>().texture == null) { craftableItemSlot.GetComponent<RawImage>().texture = itemIcon; itemIcon = null; transform.position = startingPos; craftableItemSlot.GetComponent<CraftableItem>().CheckForRequiredItems(); break; } else { transform.position = startingPos; } } } // get the closest slot so we can switch positions Transform closestSlot = GetClosestSlot(slots); // switch positions transform.position = closestSlot.position; closestSlot.position = startingPos; } }

No tengo idea de lo que está pasando porque mouseX y mouseY están sentados en la esquina y no debería ser así, cuando imprimo los valores son estos pequeños números decimales pero estoy multiplicando por 1000. ¿Estoy usando el eje incorrecto o alguien me puede decir como solucionarlo porque estoy atascado.

¡Gracias!

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!