Search Unity

Ecs Models are morphing when moving in jobs

Discussion in 'Entity Component System' started by tommox86, Jul 5, 2019.

  1. tommox86

    tommox86

    Joined:
    Apr 30, 2015
    Posts:
    88
    using Vector3.MoveTowards to move units within the jobs system causes the units scale to oscilate while on path to destination. The Unit scales thin, then scales back to its normal scale.. What could be causing this?

    Code (CSharp):
    1.  
    2.   public void Execute(Entity entity, int index, ref Rotation rotation, ref unitTag unit, ref parentData pData, ref Translation position)
    3.         {
    4. unit.rot = Quaternion.LookRotation(position.Value - pData.destination);
    5.                 unit.rot.x = 0.0f;
    6.                 unit.rot.z = 0.0f;
    7.              
    8.      
    9.                 rotation.Value = Quaternion.Slerp(rotation.Value, unit.rot, deltaTime * 15f);
    10.  
    11.                 position.Value = Vector3.MoveTowards(position.Value, new float3(pData.destination.x, pData.destination.y + unit.unitHieght, pData.destination.z), pData.unitSpeed * deltaTime);
    12.  
    13. }
    14.  
     
    Last edited: Jul 5, 2019
  2. tommox86

    tommox86

    Joined:
    Apr 30, 2015
    Posts:
    88
    using Vector3.RotateTowards the problem doesn't occur .
     
  3. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,761
    You've really given us nothing to work with

    what is unit.rot?
    where is it being used?
    why are you storing 2 versions of rot, rotation and unit.rot?
     
  4. tommox86

    tommox86

    Joined:
    Apr 30, 2015
    Posts:
    88
    yeh i tried to delete the post when i figured Vector3.RotateTowards worked.
    unit.rot = quaternion stored within component tag unit

    i have updated the code , being used within a job..