Search Unity

Rotation Lock frustration

Discussion in 'Prefabs' started by Hamu_Art, Jul 20, 2021.

  1. Hamu_Art

    Hamu_Art

    Joined:
    Apr 24, 2020
    Posts:
    15
    Hello

    In Prefab I have an animated mesh and I want to put a blobshadow under it. The problem is that the shadow rotates as the mesh rotates.
    I tried the following:
    I gave Rigidbody to the Blobshadow and under Constrain I ticked all the axes of Freeze Rotation. It didn't work.
    I tried other scripts that promise to lock it, but none of them worked.
    Is there something else I need to turn on somewhere in the engine that I have overlooked?
     
  2. DejaMooGames

    DejaMooGames

    Joined:
    Apr 1, 2019
    Posts:
    108
    This probably isn't the correct forum for this question, but here are my two cents.

    The rotation constraints will only affect the object locally so if the parent rotates it will still rotate. I suggest you write a script to force the blob shadow GameObject to follow the mesh while not being a child of it.

    Code (CSharp):
    1. public void LateUpdate()
    2. {
    3.    followingTransform.position = followedMeshTransform.position;
    4. }
    This should do the trick in the simplest fashion, but there are surely alterations that need to be made to that code in order for it to work for your specific use case.
     
  3. Hamu_Art

    Hamu_Art

    Joined:
    Apr 24, 2020
    Posts:
    15
    Thank you your help! I will check it!