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 Prefab Renders incorrectly in Subscene

Discussion in 'Entity Component System' started by Misterturtle, Sep 16, 2023.

  1. Misterturtle

    Misterturtle

    Joined:
    May 25, 2017
    Posts:
    20
    Hi all,

    I have a prefab that I want to Instantiate inside of ECS, however, when I Instantiate it, the prefab appears partially rotated?

    While the end goal is to Instantiate it in a script, I have isolated the issue to simply rendering the prefab inside of a subscene.

    The zombie on the right is added normally, outside of the subscene. The zombie on the left is added inside the subscene. This screenshot was taken without the game running, so no scripts are affecting the transform.

    I'm new to ECS, but I'm starting to think this is a bug with skinned mesh renderers because the "debug plane" that I added is not modified/rotated - only the armature hierarchy.

    To be clear: this also happens when spawning the zombie at run-time through the spawner/baking pattern.

    Any suggestions on how to continue debugging this?

    upload_2023-9-16_13-53-10.png
     
  2. Misterturtle

    Misterturtle

    Joined:
    May 25, 2017
    Posts:
    20
    To isolate the issue further, I created a new project to recreate the behavior:

    - Create HDRP project
    - Install Entities 1.0.16
    - Install Entities Graphics 1.0.16
    - Install Netcode for Entities 1.0.17
    - Import the following zombie asset: https://assetstore.unity.com/packages/3d/characters/humanoids/zombie-30232
    - Convert all built-in mats to HDRP materials
    - Create a subscene
    - Drag the Zombie prefab from the asset into the subscene

    Results in the following:

    upload_2023-9-16_14-33-57.png
     
  3. Rukhanka

    Rukhanka

    Joined:
    Dec 14, 2022
    Posts:
    177
  4. Misterturtle

    Misterturtle

    Joined:
    May 25, 2017
    Posts:
    20

    Hah! Of course you would have the answer Rukhanka :D I've been eyeing your ECS animation system for once I learn ECS a bit more extensively. Didn't realize just rendering basic skinned meshes uses experimental features.

    Forgive me for the under-educated follow up question, but I haven't gotten to collision detection yet - Is the geometry of skinned mesh renderers considered when using Unity.Physics? (Unity.Physics is the solution for ECS collision detection, right?). Also, does your ECS Animation system integrate with Unity.Physics? For example if a raycast query collides with the geometry deformation result of an animation, would that be a hit?
     
  5. Rukhanka

    Rukhanka

    Joined:
    Dec 14, 2022
    Posts:
    177
    Unity physics will work with Rukhanka in upcoming v1.4.0. It will not work with current version because Unity.Physics requires unparented Entity for its rigid bodies. But current version of Rukhanka requires strict entities bone hierarchy. v1.4.0 will lift this requirement:

     
  6. Misterturtle

    Misterturtle

    Joined:
    May 25, 2017
    Posts:
    20

    Wonderful! I most certainly will be buying your asset in the next few days and eagerly looking forward to v1.4.0. Guess I'm off to learn Unity.Physics package.

    For future reference, I confirmed Rukhanka solution worked for me. Video guide @ 45 seconds: