Answers for "transform relative to parent unity"

C#
2

unity change position relative to parent

Use transform.localPosition instead of transform.position.
Works the same as transform.position if there is no parent.

Example :

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour
{
    void Example()
    {
        // Move the object to the same position as the parent:
        transform.localPosition = new Vector3(0, 0, 0);

        // Get the y component of the position relative to the parent
        // and print it to the Console
        print(transform.localPosition.y);
    }
}
Posted by: Guest on February-06-2021

Code answers related to "transform relative to parent unity"

C# Answers by Framework

Browse Popular Code Answers by Language