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

259
Views
Acelerómetro virtual en Unity

He visto muchos tutoriales sobre cómo usar el acelerómetro de un teléfono inteligente como entrada para controlar un objeto en Unity, pero ¿es posible simular un acelerómetro triaxial en Unity?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Esencialmente, puede obtener la "aceleración" (también conocida como la velocidad) de un objeto dividiendo la distancia recorrida en el tiempo. En este caso, eso significa dividir un Vector3 en variables xyz individuales, luego calcular la velocidad en cada una y volver a colocarlas en un Vector3.

Código:

 Vector3 lastPos; void Start() { lastPos = transform.position; } void Update() { // define velocities as currentPos-lastPos(change) over time per frame, which gets velocity this frame... will be saved every frame float xVelocity = (transform.position.x-lastPos.x)/Time.deltaTime; float yVelocity = (transform.position.y-lastPos.y)/Time.deltaTime; float zVelocity = (transform.position.z-lastPos.z)/Time.deltaTime; // Do stuff with individual velocities(xyz) // ... // or store in Vector3 Vector3 totalVelocity = new Vector3(xVelocity, yVelocity, zVelocity); // Do stuff with total velocity // ... // Set lastPos to transform.position (WARNING: Only do after you are done calculating velocity lastPos = transform.position; }

over 4 years ago · Santiago Trujillo Report
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!