Use Unity's Transform.LookAt to orient a GameObject towards another but applying a custom "up" vector derived from the angle between two other GameObjects

  • Κατάσταση: Closed
  • Βραβείο: £40
  • Ληφθείσες Συμμετοχές: 4
  • Νικητής: joeyabuki

Σύνοψη Διαγωνισμού

I have a Unity project which contains a pair of glasses, and three control points: a left eye, a right eye, a nose. The pair of glasses is supposed to be positioned, scaled and oriented so that the left and right eye control points sit within the pair of glasses, and the glasses are angled so they point towards the nose control point.

I've created an Orient.cs component that does this (in Editor mode) but it doesn't respect the tilt angle of the eyes, because it relies on Transform.LookAt with Vector3.up to establish which was is up. However, I can't figure out how to derive the proper angle using the three control points I have.

I need someone knowledgable with 3D geometry, who understands Unity's geometry system, and who can write clean C# code to show me how it would work.

ZIP file attached of my Unity 2017.3.1f1 project with everything in. It's as simple as I could make it. Please post a screen recording of your fix to Orient.cs, demonstrating the glasses behave correctly (also include the actual code so I can check it myself) and I will pick the first solution which is the cleanest/simplest/properly functioning entry.

I'm sure to the right developer, this is a 1-line piece of code. It should be an easy win!

Thank you!

Προτεινόμενες Δεξιότητες

Σχόλια Εργοδότη

“Malek was quick, efficient and a pleasure to work with. He was the only freelancer I found that delivered exactly what I wanted, without any unexpected issues, first time and without fuss. Highly recommended!”

Εικόνα προφίλ adrianward, United Kingdom.

Κορυφαίες καταχωρήσεις από αυτόν τον διαγωνισμό

Προβολή Περισσότερων Συμμετοχών

Δημόσιος Πίνακας Διευκρινίσεων

  • adrianward
    Κάτοχος Διαγωνισμού
    • Πριν από 6 χρόνια

    Hi, please see this video which demonstrates the limitation of my current solution. When I rotate the red and green control points (the left and right eyes) the glasses should tilt too. https://www.dropbox.com/s/4fxxcaorjcxca60/180320%203DResolve%20problem.mov?dl=0

    • Πριν από 6 χρόνια
  • joeyabuki
    joeyabuki
    • Πριν από 6 χρόνια

    Hi , can u explain more about "doesn't respect the tilt angle of the eyes, "

    • Πριν από 6 χρόνια

Πώς να ξεκινήσετε με τους διαγωνισμούς

  • Δημοσιεύστε τον διαγωνισμό σας

    Αναρτήστε τον διαγωνισμό σας Γρήγορα και εύκολα

  • Λάβε ένα σωρό συμμετοχές

    Λάβετε Πολλές Συμμετοχές Από όλο τον κόσμο

  • Βραβεύστε την καλύτερη καταχώρηση

    Βραβεύστε την καλύτερη καταχώρηση Κατεβάστε τα αρχεία - Εύκολα!

Αναρτήστε ένα Διαγωνισμό Τώρα ή Ελάτε Μαζί Μας Σήμερα!