Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Entity Translation is NaN after adding DynamicBuffer

Discussion in 'Entity Component System' started by DirectCherry, Mar 12, 2020.

  1. DirectCherry

    DirectCherry

    Joined:
    May 29, 2019
    Posts:
    4
    I have an entity that is being created through the Convert To Entity component (Convert and Destroy) and it seems to work fine (placing the entity where the GameObject was) until I add a DynamicBuffer to the entity.

    Before adding the buffer:
    Translation = (45, 4.52, -59.5)

    After adding the buffer:
    Translation = (NaN, 3.4028, NaN)

    My DynamicBuffer element:
    Code (CSharp):
    1. [InternalBufferCapacity(12)]
    2. public struct PathBufferElement : IBufferElementData
    3. {
    4.     // These implicit conversions are optional, but can help reduce typing.
    5.     public static implicit operator NavMeshLocation(PathBufferElement e) { return e.Value; }
    6.     public static implicit operator PathBufferElement(NavMeshLocation e) { return new PathBufferElement { Value = e }; }
    7.  
    8.     // Actual value each buffer element will store.
    9.     public NavMeshLocation Value;
    10. }
    What is causing this weird behaviour?