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


C# Ray.GetPoint方法代码示例

本文整理汇总了C#中UnityEngine.Ray.GetPoint方法的典型用法代码示例。如果您正苦于以下问题:C# Ray.GetPoint方法的具体用法?C# Ray.GetPoint怎么用?C# Ray.GetPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEngine.Ray的用法示例。


在下文中一共展示了Ray.GetPoint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GizmoTest

    private static void GizmoTest(Transform aTarget, GizmoType aGizmoType)
    {
        #if UNITY_EDITOR
        if (Application.isPlaying)
        {
            ThirdPersonMotor motor = (ThirdPersonMotor)aTarget.GetComponent<ThirdPersonMotor>();
            if (!motor) return;

            // debug auto crouch
            Vector3 posHead = motor.transform.position + Vector3.up * ((motor.colliderHeight * 0.5f) - motor.colliderRadius);
            Ray ray1 = new Ray(posHead, Vector3.up);
            Gizmos.DrawWireSphere(ray1.GetPoint((motor.headDetect - (motor.colliderRadius * 0.1f))), motor.colliderRadius * 0.9f);
            Handles.Label(ray1.GetPoint((motor.headDetect + (motor.colliderRadius))), "Head Detection");
            // debug check trigger action
            Vector3 yOffSet = new Vector3(0f, -0.5f, 0f);
            Ray ray2 = new Ray(motor.transform.position - yOffSet, motor.transform.forward);
            Debug.DrawRay(ray2.origin, ray2.direction * 0.45f, Color.white);
            Handles.Label(ray2.GetPoint(0.45f), "Check for Trigger Actions");
            // debug stopmove
            Ray ray3 = new Ray(motor.transform.position + new Vector3(0, motor.colliderHeight / 3, 0), motor.transform.forward);
            Debug.DrawRay(ray3.origin, ray3.direction * motor.stopMoveDistance, Color.blue);
            Handles.Label(ray3.GetPoint(motor.stopMoveDistance), "Check for StopMove");
            // debug stopmove
            Ray ray4 = new Ray(motor.transform.position + new Vector3(0, motor.colliderHeight / 3.5f, 0), motor.transform.forward);
            Debug.DrawRay(ray4.origin, ray4.direction * 1f, Color.cyan);
            Handles.Label(ray4.GetPoint(1f), "Check for SlopeLimit");
            // debug stepOffset
        //            Ray ray5 = new Ray((motor.transform.position + new Vector3(0, motor.stepOffsetEnd, 0) + motor.transform.forward * ((motor.capsuleCollider).radius + motor.stepOffsetFwd)), Vector3.down);
        //            Debug.DrawRay(ray5.origin, ray5.direction * (motor.stepOffsetEnd - motor.stepOffsetStart), Color.yellow);
        //            Handles.Label(ray5.origin, "Step OffSet");
        }
        #endif
    }
开发者ID:yenv672,项目名称:thesis,代码行数:33,代码来源:CharacterEditor.cs

示例2: Continue

 protected override bool Continue()
 {
     float single;
     float single1 = (float)(HUDIndicator.stepTime - this.startTime);
     if (single1 > this.curve[this.curve.length - 1].time)
     {
         return false;
     }
     this.material.Set("_AlphaValue", Mathf.Clamp(this.curve.Evaluate(single1), 0.003921569f, 0.996078432f));
     if (this.followPoint)
     {
         Vector3 vector3 = base.transform.position;
         Vector3 point = base.GetPoint(HUDIndicator.PlacementSpace.World, this.worldPosition);
         if (vector3.z != point.z)
         {
             Plane plane = new Plane(-base.transform.forward, vector3);
             Ray ray = new Ray(point, Vector3.forward);
             if (!plane.Raycast(ray, out single))
             {
                 ray.direction = -ray.direction;
                 point = (!plane.Raycast(ray, out single) ? vector3 : ray.GetPoint(single));
             }
             else
             {
                 point = ray.GetPoint(single);
             }
         }
         if (point != vector3)
         {
             base.transform.position = point;
         }
     }
     return true;
 }
开发者ID:HexHash,项目名称:LegacyRust,代码行数:34,代码来源:HUDHitIndicator.cs

示例3: drawFloorExample

 void drawFloorExample(Vector3 left, Vector3 right, float length)
 {
     Ray lr = new Ray(left, new Vector3(focusedCamera.transform.forward.x, 0, focusedCamera.transform.forward.z));
     Ray rr = new Ray(right, new Vector3(focusedCamera.transform.forward.x, 0, focusedCamera.transform.forward.z));
     Vector3 center = (left + right + lr.GetPoint(length) + rr.GetPoint(length)) * 0.25F;
     Gizmos.DrawCube(center , new Vector3(Vector3.Distance(left, right), 0.01F, Vector3.Distance(left, lr.GetPoint(length))));
     if(displayTextInformation)
         Gizmos.DrawIcon(center, "TableTopHeight.png");
 }
开发者ID:jacthoma,项目名称:Project-Elephant,代码行数:9,代码来源:DebugBounds.cs

示例4: drawLineFromCameraPastPoint

    void drawLineFromCameraPastPoint(Vector3 v, float length)
    {
        Ray r = new Ray(v, v - focusedCamera.transform.position);
        Gizmos.DrawLine(v, r.GetPoint(length));

        if(displayTextInformation)
            Gizmos.DrawIcon(r.GetPoint(length), "EdgeOfViewDistance.png");
        else
            Gizmos.DrawSphere(r.GetPoint(length), 0.02F);
    }
开发者ID:jacthoma,项目名称:Project-Elephant,代码行数:10,代码来源:DebugBounds.cs

示例5: Update

    void Update()
    {
        if(moving == true){
           //ray  = Camera.main.ScreenPointToRay (Input.mousePosition);
            ray = mainCamera.ScreenPointToRay(Input.mousePosition);
           //The Object is 14 away from the camera,
           Debug.Log(ray.GetPoint(14));
           //rigidbody.MovePosition(rigidbody.position + ray.GetPoint(14) * Time.deltaTime);
           selfPosition.x = ray.GetPoint(14).x;
           selfPosition.y = ray.GetPoint(14).y;
           selfPosition.z = 1.1f;

           transform.position = selfPosition;
        }
    }
开发者ID:Shadowist,项目名称:OGM2013February,代码行数:15,代码来源:ClickAndDrag.cs

示例6: Laser

    IEnumerator Laser()
    {
        line.enabled = true;

        while (Input.GetButton("Fire1"))
        {

            Ray rayObj = new Ray(transform.position, transform.forward);

            line.SetPosition(0, rayObj.origin);

            if (Physics.Raycast(rayObj, out rayHit))
            {

                line.SetPosition(1, rayHit.point);
                // Debug.Log(rayHit.collider.tag);

                if (rayHit.collider.tag == "Enemy")
                    EnemyHit = true;

            }

            line.SetPosition(1, rayObj.GetPoint(100));

            yield return null;

        }

        line.enabled = false;
    }
开发者ID:talhahasanzia,项目名称:MazeBot,代码行数:30,代码来源:LaserScript.cs

示例7: Update

    // Update is called once per frame
    void Update()
    {
        frame = lp.CurrentFrame;
        if (frame.Hands.Count > 0) {
            if (frame.Hands.Leftmost.IsLeft) {
                righty = frame.Hands.Leftmost;
                rfingers = right.fingers;
            }
        }

        if (right.isActiveAndEnabled) {
            if (Vector3.Distance (right.GetPalmPosition (), rfingers [0].GetTipPosition ()) > trigger &&
                Vector3.Distance (right.GetPalmPosition (), rfingers [1].GetTipPosition ()) > trigger &&
                Vector3.Distance (right.GetPalmPosition (), rfingers [2].GetTipPosition ()) < trigger &&
                Vector3.Distance (right.GetPalmPosition (), rfingers [3].GetTipPosition ()) < trigger &&
                Vector3.Distance (right.GetPalmPosition (), rfingers [4].GetTipPosition ()) < trigger ) {
                Debug.Log ("rockgod!!");
                rockgod = true;
            } else {
                rockgod = false;
            }
            if (rockgod) {
                line.enabled = true;
                Ray ray = new Ray (rfingers [1].GetTipPosition (), rfingers[1].GetBoneDirection(2));
        //				Ray ray1 = new Ray (rfingers [4].GetTipPosition (), rfingers [4].GetBoneDirection ());

                line.SetPosition (0, ray.origin);
                line.SetPosition (1, ray.GetPoint (100));
            } else {
                line.enabled = false;
            }
        }
    }
开发者ID:VRWizards,项目名称:VR-Project,代码行数:34,代码来源:LeftGun.cs

示例8: LineCast

 private static Vector3 LineCast(Plane plane, Vector3 a, Vector3 b)
 {
     float dis;
     Ray ray = new Ray(a, b-a);
     plane.Raycast( ray, out dis );
     return ray.GetPoint(dis);
 }
开发者ID:OSW-team,项目名称:Project-4,代码行数:7,代码来源:CausticDecalPolygon.cs

示例9: Update

 void Update() {
   Vector3 forward = RaycastSource.TransformDirection(Vector3.forward);
   bool didHit = Physics.Raycast(RaycastSource.position, forward, out hit, MaxDistance, Collidable);
   if (ObjectToPosition != null) {
     if (didHit) {
       ObjectToPosition.transform.position = hit.point;
       lastLegalPlane.SetNormalAndPosition(Vector3.up, 
                                           new Vector3(0, ObjectToPosition.transform.position.y, 0));
     } else {
       Ray castRay = new Ray(RaycastSource.transform.position, RaycastSource.transform.forward);
       float rayDistance;
       if (lastLegalPlane.Raycast(castRay, out rayDistance)) {
         ObjectToPosition.transform.position = castRay.GetPoint(rayDistance);
       }
     }
   }
   if (UseLineRenderer) {
     if (didHit) {
       if (Line.gameObject.activeSelf == false) {
         Line.gameObject.SetActive(true);
       }
       Line.SetPosition(0, RaycastSource.transform.position);
       Line.SetPosition(1, ObjectToPosition.transform.position);
     } else if (Line.gameObject.activeSelf == true)
       Line.gameObject.SetActive(false);
   }
 }
开发者ID:MaTriXy,项目名称:cardboard-unity,代码行数:27,代码来源:RaycastPositioner.cs

示例10: RaycastSmoke

		public static bool RaycastSmoke(Ray ray)
		{
			if(!CMDropper.smokePool)
			{
				return false;
			}

			for(int i = 0; i < CMDropper.smokePool.size; i++)
			{
				Transform smokeTf = CMDropper.smokePool.GetPooledObject(i).transform;
				if(smokeTf.gameObject.activeInHierarchy)
				{
					Plane smokePlane = new Plane((ray.origin-smokeTf.position).normalized, smokeTf.position);
					float enter;
					if(smokePlane.Raycast(ray, out enter))
					{
						float dist = (ray.GetPoint(enter)-smokeTf.position).magnitude;
						if(dist < 16)
						{
							return true;
						}
					}
				}
			}

			return false;
		}
开发者ID:tetryds,项目名称:BDArmory,代码行数:27,代码来源:CMSmoke.cs

示例11: ScanSpace

    void ScanSpace()
    {
        // в direction переписываем готовые координаты X и Z, идя по радиусу rEnemyScan
        pPos = parentObject.transform.position;	// отсутп от родителя
        Vector3 pos = new Vector3((Mathf.Sin (angle * Mathf.Deg2Rad) * MyContext.stepaside) + pPos.x, transform.position.y, (Mathf.Cos (angle * Mathf.Deg2Rad) * MyContext.stepaside) + pPos.z);
        transform.position = pos;
        Quaternion rot = Quaternion.Euler(0, angle, 0);
        transform.rotation = rot;
        locator = new Ray (transform.position, transform.forward);
        line.SetPosition (0, locator.origin);
        //если во чтото попали
        if (Physics.Raycast(transform.position, transform.forward, out hit, MyContext.rEnemyScan))
        {
            //если попали в игрока, то держим на нём взгляд
            if (hit.transform.gameObject.tag == "Player")
            {
                targetObject = hit.transform.gameObject;
                search = false;
                return;
            }
            //иначе обрубаем луч на первом коллаедре
            else
                line.SetPosition(1, hit.point);
        }
        //если не попали
        else
            line.SetPosition(1, locator.GetPoint(MyContext.rEnemyScan));

        //прибавляем угол
        if (angle >= 359) {angle = 0;} else angle += MyContext.scanSpeed; // скидываем угол на 0 при 359 градусах
    }
开发者ID:shaunthesheep32,项目名称:BalanceSample,代码行数:31,代码来源:EnemyLocator.cs

示例12: Update

    void Update()
    {
        if (null != mirrorPlane) {
            if (null != objectBeforeMirror) {
                transform.position = objectBeforeMirror.transform.position;
                transform.rotation = objectBeforeMirror.transform.rotation;

                Vector3 positionInMirrorSpace = mirrorPlane.transform.InverseTransformPoint( objectBeforeMirror.transform.position );

                // move camera forward
                positionInMirrorSpace.y = -positionInMirrorSpace.y;
                positionInMirrorSpace.z = (positionInMirrorSpace.z)/2.5f;

                transform.position = mirrorPlane.transform.TransformPoint( positionInMirrorSpace );

                /** object is now in correct position, but looking in parallel look direction to original */
                /* So, cast a ray from the original object along look-direction until you hit the plane,
                 * then make the cloned object "look at" that position */
                Vector3 mirrorsNormal = mirrorPlane.transform.localRotation * new Vector3( 0f, 1, 0f ); // Unity planes always start with normal pointing up
                Plane planeOfMirror = new Plane(  mirrorsNormal, mirrorPlane.transform.position );
                float intersectionDistance;
                Ray rayToMirror = new Ray( objectBeforeMirror.transform.position, objectBeforeMirror.transform.forward );
                planeOfMirror.Raycast( rayToMirror, out intersectionDistance );
                Vector3 hitPoint = rayToMirror.GetPoint( intersectionDistance );

                transform.LookAt( hitPoint );
            }
        }
    }
开发者ID:valeriejean,项目名称:pippin,代码行数:29,代码来源:MirrorMirrifyObject.cs

示例13: FireLaser

    IEnumerator FireLaser()
    {
        line.enabled = true;
        gameObject.GetComponent<Light> ().enabled = true;

        while (Input.GetButton ("Fire1"))
        {

            Ray ray = new Ray (transform.position, transform.forward);
            RaycastHit hit;

            line.SetPosition (0, ray.origin);

            if (Physics.Raycast (ray, out hit, 100)) {
                line.SetPosition (1, hit.point);
                if (hit.rigidbody)
                {
                    hit.rigidbody.AddForceAtPosition (transform.forward * 100, hit.point);
                }
            }
            else
                line.SetPosition (1, ray.GetPoint (100));

            yield return null;
        }

        line.enabled = false;
        gameObject.GetComponent<Light> ().enabled = false;
    }
开发者ID:entropyofchaos,项目名称:KinectJediTrainer,代码行数:29,代码来源:LaserScript.cs

示例14: ShootELaser

    IEnumerator ShootELaser()
    {
        eLine.enabled = true;

        eLine.GetComponent<Renderer>().material.mainTextureOffset = new Vector2(0, Time.time);

        Ray ray = new Ray();
        ray = eC.ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2, 0));
        RaycastHit hit;

        eLine.SetPosition(0, eShotPoint);

        if (Physics.Raycast(ray, out hit, 100))
        {
            eLine.SetPosition(1, hit.point);
            if (hit.collider.tag == "Player")
            {
                HUD.playerHit = true;
                HUD.score -= 100;
            }
            Instantiate(eLaserParticles, hit.point, eParticleRotation.transform.rotation);
        }
        else
        {
            eLine.SetPosition(1, ray.GetPoint(100));
        }
        eLaserShot = true;
        yield return null;
    }
开发者ID:Laantje,项目名称:Power-Laser,代码行数:29,代码来源:EnemyLaser.cs

示例15: fireLaserOnce

 void fireLaserOnce()
 {
     Ray ray = new Ray (cam.transform.position, cam.transform.forward);
     RaycastHit hit;
     if (Input.GetButtonDown ("Fire1")) {
         line.SetPosition (0, transform.Find ("laserspawn").position);
         if (!AddForce)
         {
             line.enabled = true;
             if (Physics.Raycast (ray, out hit, 100)) {
                 line.SetPosition (1, hit.point);
                 hit.transform.SendMessage ("damage", dmg, SendMessageOptions.DontRequireReceiver);
             } else {
                 line.SetPosition (1, ray.GetPoint (60));
             }
        } else {
             line.enabled = true;
             if (Physics.Raycast (ray, out hit, 100)) {
                 line.SetPosition (1, hit.point);
                 if (hit.rigidbody){
                     hit.rigidbody.AddForceAtPosition(transform.forward * force, hit.point);
                     Debug.Log("Rigidbody " + hit.transform.gameObject.name + " Hit!");
                 }
             } else {
                 line.SetPosition (1, ray.GetPoint (60));
             }
         }
     }
     if (line.enabled == true){
         DestroyTimer(0.05f);
     }
 }
开发者ID:sharkbound,项目名称:Unity-Projects,代码行数:32,代码来源:raycast.cs


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