本文整理汇总了C#中UnityEngine.GameObject.InverseTransformPoint方法的典型用法代码示例。如果您正苦于以下问题:C# GameObject.InverseTransformPoint方法的具体用法?C# GameObject.InverseTransformPoint怎么用?C# GameObject.InverseTransformPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.GameObject
的用法示例。
在下文中一共展示了GameObject.InverseTransformPoint方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnUpdate
public override void OnUpdate()
{
base.OnUpdate();
if (!HighLogic.LoadedSceneIsFlight)
return;
if (!invertSet) //run only the first time the craft is loaded
{
// test whether the engine is on the left or right side of the craft, for inverting the engine rotation and thrust based roll.
if (Vector3.Dot(partTransform.position.normalized, vessel.ReferenceTransform.right) < 0) // below 0 means the engine is on the left side of the craft
{
invertRotation = true;
//Debug.Log("Inverting left side VTOL rotation");
}
else
{
invertRotation = false;
}
if (startInverted)
invertRotation = !invertRotation;
}
invertSet = true;
if (!isInFrontOfCoMSet)
{
// test whether the engine is in the front or rear of the craft, for using double engine pair thrust based pitch.
Transform CoMTransform = new GameObject().transform;
CoMTransform.position = vessel.CoM;
CoMTransform.rotation = vessel.transform.rotation;
Vector3 relativePosition = CoMTransform.InverseTransformPoint(part.transform.position);
if (relativePosition.y < 0)
{
//Debug.Log("FSVTOLrotator: Engine is behind CoM: " + relativePosition);
isInFrontOfCoM = false;
}
else
{
//Debug.Log("FSVTOLrotator: Engine is in front of CoM: " + relativePosition);
isInFrontOfCoM = true;
}
}
isInFrontOfCoMSet = true;
updateButtonTexts();
#region VTOL steering
FlightCtrlState ctrl = vessel.ctrlState;
steerAngle = 0f;
atmosphericNerf.steeringModifier = 1f;
if (VTOLsteeringActive)
{
if (steerPitch)
{
if (steerThrottlePitch)
{
float steerModifier = ctrl.pitch * SteeringMaxPitchThrottle;
if (isInFrontOfCoM)
steerModifier *= -1;
atmosphericNerf.steeringModifier -= steerModifier * steerDirection;
}
else
{
steerAngle -= ctrl.pitch * SteeringMaxPitch * steerDirection;
if (invertRotation)
steerAngle *= -1;
}
}
if (steerYaw)
{
steerAngle -= ctrl.yaw * SteeringMaxYaw * steerDirection;
}
if (steerRoll)
{
float steerModifier = ctrl.roll * SteeringMaxRoll;
if (invertRotation)
steerModifier *= -1;
atmosphericNerf.steeringModifier -= steerModifier * steerDirection;
}
}
#endregion
}
示例2: CreateStructure
public void CreateStructure(bool isRepair = false, bool addColliders = true)
{
if (this._wasBuilt && isRepair)
{
if (this._bridgeRoot)
{
UnityEngine.Object.Destroy(this._bridgeRoot.gameObject);
}
this._bridgeRoot = null;
base.StartCoroutine(this.DelayedAwake(true));
}
GameObject gameObject = (!this._bridgeRoot) ? null : this._bridgeRoot.gameObject;
this._bridgeRoot = this.CreateBridge(this._anchor1.transform.position, this._anchor2.transform.position);
this._bridgeRoot.name = "BridgeRoot" + ((!addColliders) ? "Ghost" : "Built");
this._bridgeRoot.parent = base.transform;
if (gameObject)
{
UnityEngine.Object.Destroy(gameObject);
}
if (addColliders)
{
base.transform.position = this._anchor1.transform.position;
this._bridgeRoot.parent = base.transform;
Vector3 vector = this._bridgeRoot.GetChild(0).position;
int num = Mathf.CeilToInt(Vector3.Distance(this._anchor1.transform.position, this._anchor2.transform.position) / this._maxColliderLength);
int num2 = Mathf.CeilToInt((float)this._bridgeRoot.childCount / (float)num);
for (int i = 1; i <= num; i++)
{
int num3 = num2 * i;
if (num3 >= this._bridgeRoot.childCount)
{
num3 = this._bridgeRoot.childCount - 1;
}
Transform child = this._bridgeRoot.GetChild(num3);
Vector3 position = child.position;
Transform transform = new GameObject("Floor" + i).transform;
transform.parent = base.transform;
transform.position = vector;
transform.LookAt(position);
BoxCollider boxCollider = transform.gameObject.AddComponent<BoxCollider>();
boxCollider.center = transform.InverseTransformPoint(Vector3.Lerp(vector, position, 0.5f));
boxCollider.size = new Vector3(4.5f, this._logWidth, Vector3.Distance(vector, position));
transform.tag = "UnderfootWood";
vector = position;
}
}
if (this._wasBuilt && isRepair)
{
this._bridgeRoot.parent = base.transform;
}
}