Search Unity

Inspector position does not match Debug.Log

Discussion in 'Scripting' started by KeithW, Jul 3, 2018.

  1. KeithW

    KeithW

    Joined:
    Dec 15, 2017
    Posts:
    9
    FireTruck(Clone) does not have the values in the Inspector that Debug.Log reports. Why?
    The values reported in Debug.Log are the ones we want
    There is only one FireTruck.

    Code
    Code (CSharp):
    1. GameObject modelCopy = Instantiate(model, null);
    2. modelCopy.transform.SetParent(go.transform, true);
    3. Quaternion modelRotation = Quaternion.Euler(Vector3.zero);
    4. Vector3 modelPosition = new Vector3(0, 0, 0); // modelTransform.position;
    5. modelCopy.transform.SetPositionAndRotation(modelPosition, modelRotation);
    6. Vector3 modelScale = modelTransform.localScale;
    7. modelCopy.transform.localScale = new Vector3(modelScale.x, modelScale.y, modelScale.z);
    8. Debug.Log("LoadScene gameObject " + go.name);
    9. // report GameObject name, position, rotation euler angles, and scale to 5 decimal places
    10. ShowGOTransform(go);
    11. ShowGOTransform(modelCopy);
    Debug.Log output
    LoadScene gameObject node_FireTruck_1
    2018/07/03 12:08:34.039

    go node_FireTruck_1 position ( 362.64710, 11.00000, 257.88430 ) rotation ( 0.00000, 315.00000, 0.00000 ) scale ( 0.08333, 0.08333, 0.08333 )
    2018/07/03 12:08:34.040

    go FireTruck(Clone) position ( -0.00003, 0.00000, -0.00003 ) rotation ( 0.00000, 0.00000, 0.00000 ) scale ( 1.00000, 1.00000, 1.00000 )
    2018/07/03 12:08:34.041

    From Inspector

    FireTruck_1 looks exactly like it should

    However, FireTruck(Clone) (the only node under FireTruck_1) does not.
     
  2. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712