当前位置: 首页>>代码示例>>C#>>正文


C# GameObject.InverseTransformPoint方法代码示例

本文整理汇总了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
        }
开发者ID:KevinMilcz,项目名称:Firespitter,代码行数:86,代码来源:FSVTOLrotator.cs

示例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;
     }
 }
开发者ID:GameDiffs,项目名称:TheForest,代码行数:51,代码来源:BridgeArchitect.cs


注:本文中的UnityEngine.GameObject.InverseTransformPoint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。