Search Unity

Any support method of 'Transform.RotateAround' in Job system?

Discussion in 'Data Oriented Technology Stack' started by ChocoHime, Sep 23, 2018.

  1. ChocoHime

    ChocoHime

    Joined:
    Aug 25, 2018
    Posts:
    3
    Well, i'm a beginner of ECS and Job system.

    I'm studying Hybrid + Job system after i completed study about Hybrid ECS.

    But in the Job system, you know, we can't get data or method from main thread. It'll give us error.

    So i realize why they made 'Unity.Transforms' and 'Unity.Mathematics'. Cause we can't use old Transform in the Job System.

    And i searched a lot, but i can't find method which work like 'Transform.RotateAround'.
    Even UnityEngine.Jobs.TransformActive and Unity.Mathematics.quaternion don't have that method. They just have 'LookRotation'.

    So is any support method of 'Transform.RotateAround' in ECS system?
     
  2. Soaryn

    Soaryn

    Joined:
    Apr 17, 2015
    Posts:
    198
    You can make your own method. I recommend, if you havent already try out Jetbrains rider, as it makes seeing the root code a lot easier by Ctrl clicking the method name to inspect it.

    Example:
    Code (CSharp):
    1. public static float3 RotateAroundPoint(float3 position, float3 pivot, float3 axis, float delta) => math.mul(quaternion.axisAngle(axis, delta), position - pivot) + pivot;
    position is where your object is
    pivot is the point that you are rotating around
    axis is the rotational axis
    delta is the speed at which you rotate

    This can more than likely be improve a bit, but it works.
     
    proandrius likes this.
  3. ChocoHime

    ChocoHime

    Joined:
    Aug 25, 2018
    Posts:
    3
    Thanks for a nice code! i'm not good at 3D math, so i'm so frustrated :(
     
  4. Soaryn

    Soaryn

    Joined:
    Apr 17, 2015
    Posts:
    198
    Hence why I recommended the look into Rider, as it you could potentially work out the translation from Transform logic to ECS logic
     
  5. ChocoHime

    ChocoHime

    Joined:
    Aug 25, 2018
    Posts:
    3
    Oh, that'll be useful. I will try JetBrains rider. Thanks!