Unity 机器学习代理工具包 (ML-Agents) 是一个开源项目,它使游戏和模拟能够作为训练智能代理的环境。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 

26 行
939 B

using UnityEngine;
/// <summary>
/// A Transform Extension that ignores scale for TransformPoint operations.
/// </summary>
public static class TransformExtensions
{
/// <summary>
/// Transform position from world space to local space unscaled.
/// </summary>
public static Vector3 TransformPointUnscaled(this Transform transform, Vector3 position)
{
var localToWorldMatrix = Matrix4x4.TRS(transform.position, transform.rotation, Vector3.one);
return localToWorldMatrix.MultiplyPoint3x4(position);
}
/// <summary>
/// Transform position from local space to world space unscaled.
/// </summary>
public static Vector3 InverseTransformPointUnscaled(this Transform transform, Vector3 position)
{
var worldToLocalMatrix = Matrix4x4.TRS(transform.position, transform.rotation, Vector3.one).inverse;
return worldToLocalMatrix.MultiplyPoint3x4(position);
}
}