Need to distinguish between World Position and Local Position a time, changing the position of the object of the game in unity, where Position is relative to the world, Local Position is relative to the parent object, in Inpector Transform panel assembly is actually Local Positon Position .
Local Position Worl Positon be understood that the object of the game World Positon = + parent object of the game objects
For example: Capsule Cube and layered below
Capsule which the transform panel
For there is the Cube
Second, on the public Vector3 TransformPoint (Vector3 position)
My personal understanding of this method is that the parameters Vector3 position converted to the object in the world coordinate world, that the incoming parameters plus parent object of the object world position.
Test script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class transformPoint : MonoBehaviour
{
// this script is to explore the use of Transform.transformPoint
public Vector3 World_Posion, Local_Position;
public Vector3 newPosition;
void Start()
{
}
private void OnGUI()
{
if (GUILayout.Button("Test the transformPoint"))
{
this.transform.position = this.transform.TransformPoint(newPosition);
}
}
private void Update()
{
World_Posion = this.transform.position;
Local_Position = this.transform.localPosition;
}
}
The results of the Cube object with scripting are: