Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Quaternion in UVS: Can you find out why it is not working?

Discussion in 'Visual Scripting' started by Marou1, Jul 15, 2023.

  1. Marou1

    Marou1

    Joined:
    Dec 13, 2021
    Posts:
    141
    Hi,

    I have this c# code to make an enemy face its target overtime:
    upload_2023-7-15_11-44-21.png

    I made this script:
    upload_2023-7-15_11-50-28.png

    It doesn't work. The Enemy rotation does not change when the target moves around.

    I am not looking for an another way to do it, I'd like to understand what I'm doing wrong.

    Thanks!
     

    Attached Files:

  2. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    1,833
    I couldn't find a reference for the LookRotation function as called by Visual Scripting, but the API does not take in Euler angles but a direction vector. You build the direction vector but then convert it to a Quaternion by Euler angles. I think if you took out the Euler node and gave the results of Create Vector3 directly to LookRotation, you'd have a literal translation of your code.
     
  3. Marou1

    Marou1

    Joined:
    Dec 13, 2021
    Posts:
    141
    LookRotation is a variable defined as a quaternion. It is also used as quaternion with the function Quaternion Slerp, it does not take a Vect3 as input.
     
  4. nomadic

    nomadic

    Joined:
    Mar 4, 2010
    Posts:
    44
    There is no flow connected to the nodes: Euler, Create, Slerp
     
    Last edited: Jul 21, 2023
  5. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    1,754
    Doesn't need to be, nodes connected via value ports are evaluated retroactively.