Search Unity

Setting rotation from an object pool

Discussion in 'Scripting' started by Holocene, Feb 10, 2017.

  1. Holocene

    Holocene

    Joined:
    Feb 21, 2009
    Posts:
    347
    I'm calling from an object pool and able to set position correctly, but not rotation.
    Not sure why the below doesn't set rotation.
    Any thoughts?


    Code (CSharp):
    1. ObjectPoolManager.PullObject("Object1").transform.position = transform.position;
    2. ObjectPoolManager.PullObject("Object1").transform.rotation = transform.rotation;
     
  2. Gametyme

    Gametyme

    Joined:
    May 7, 2014
    Posts:
    618
    Try Quaternion.identity.
     
  3. Holocene

    Holocene

    Joined:
    Feb 21, 2009
    Posts:
    347
    Thanks, Gametyme.
    I'd like the object to follow the same rotation as the object that it's being called from.
    Either way, that didn't appear to work.
     
  4. Gametyme

    Gametyme

    Joined:
    May 7, 2014
    Posts:
    618
    Is this a moving object?
     
  5. Holocene

    Holocene

    Joined:
    Feb 21, 2009
    Posts:
    347
    No, it's a static object. What I don't understand is why the positional transform is working, but no rotation?
     
  6. Gametyme

    Gametyme

    Joined:
    May 7, 2014
    Posts:
    618
    You could try adding a spawn point and setting your spawned objects to its rotation.
     
    Last edited: Feb 10, 2017
  7. Holocene

    Holocene

    Joined:
    Feb 21, 2009
    Posts:
    347
    Yeah, that's my next test. Thanks