• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Quaternion类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Quaternion的典型用法代码示例。如果您正苦于以下问题:C# Quaternion类的具体用法?C# Quaternion怎么用?C# Quaternion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Quaternion类属于命名空间,在下文中一共展示了Quaternion类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CreateGrappleBeam

	public bool IsHoldingGrapple = false;	// if true the player is pulled alongwith the hook shot
	public void CreateGrappleBeam() {
		if (!IsGrappling) {
			HandPosition = transform.position;	// default for now
			RaycastHit hit;
			Player MyPlayer = gameObject.GetComponent<Player> ();
			if (Physics.Raycast (transform.position, MyPlayer.ShootForwardVector, out hit, 100)) {
				HandPosition = hit.point;
				Quaternion NewRotation = new Quaternion ();
				//NewRotation.eulerAngles = (hit.point - gameObject.transform.position);
				NewRotation.eulerAngles =  MyPlayer.ShootForwardVector;
				NewRotation = Quaternion.identity;
				//Debug.LogError ("Angle of Grapple: " + NewRotation.eulerAngles.ToString());
				GameObject MyChain = (GameObject)Instantiate (GrappleBeamPrefab, HandPosition, NewRotation);
				//NewRotation = MyChain.transform.rotation;
				MyChain.transform.LookAt(hit.point);
				//Debug.LogError ("Angle of Grapple: " + MyChain.transform.rotation.eulerAngles.ToString());
				if (IsHoldingGrapple) {
					//MyChain.transform.rotation = NewRotation;
					transform.position = MyChain.transform.GetChild (7).transform.position;
					Vector3 CharacterBodyOffset = new Vector3(0,-1.5f,0);
					transform.position = transform.position+CharacterBodyOffset;
					gameObject.AddComponent<FixedJoint> ();
					gameObject.GetComponent<FixedJoint> ().connectedBody = MyChain.transform.GetChild (7).GetComponent<Rigidbody> ();
					gameObject.GetComponent<CharacterController> ().enabled = false;
					IsGrappling = true;
					gameObject.GetComponent<Rigidbody>().isKinematic = false;
				}
			}
		}
	}
开发者ID:Deus0,项目名称:Zeltex,代码行数:31,代码来源:Grapple.cs


示例2: AddAvatar

 public override PhysicsCharacter AddAvatar(string avName, Vector3 position, Quaternion rotation, Vector3 size,
                                            bool isFlying, uint localID, UUID UUID)
 {
     BasicCharacterActor act = new BasicCharacterActor {Position = position, Flying = isFlying};
     _actors.Add(act);
     return act;
 }
开发者ID:nathanmarck,项目名称:Aurora-Sim,代码行数:7,代码来源:BasicPhysicsScene.cs


示例3: Fire

 public override void Fire(Vector3 direction, Quaternion rotation)
 {
     currentDistance = 0;
         base.Fire(direction,rotation);
                 BulletProjectileUp();
       amIFired = true;
 }
开发者ID:genelikespie,项目名称:AR_Game_Winter2016,代码行数:7,代码来源:BulletProjectile.cs


示例4: FindAttributes

    void FindAttributes()
    {
        getRecordedData = false;
        GhostPathRecorder temp = GameObject.FindObjectOfType<GhostPathRecorder>();
        if( temp == null ) {
            Debug.LogError( "TestLerp coulnd't find a GhostPathRecorder in he scene." );
            return;
        }
        if( temp.recordedPositions.Count < 1 || temp.recordedYRotations.Count < 1 ) {
            Debug.LogError( "The GhostPathRecorder that TestLerp found has too little sampled positions/rotations to work." );
            return;
        }

        positions = temp.recordedPositions;
        yRotations = temp.recordedYRotations;
        sampleRate = temp.sampleRate;

        thisTransform.position = positions[0];
        thisTransform.rotation = Quaternion.Euler( new Vector3( 0f, yRotations[0], 0f ) );

        currentStartPos = positions[0];
        currentEndPos = positions[1];
        currentStartRot = Quaternion.Euler( new Vector3( 0f, yRotations[0], 0f ) );
        currentEndRot = Quaternion.Euler( new Vector3( 0f, yRotations[1], 0f ) );

        isMoving = true;
        getRecordedData = false;
    }
开发者ID:paleonluna,项目名称:ASAGoSailingApp,代码行数:28,代码来源:TestLerp.cs


示例5: ControlMouse

 void ControlMouse()
 {
     Vector3 mousePos = Input.mousePosition;
     mousePos = cam.ScreenToWorldPoint (new Vector3 (mousePos.x, mousePos.y,cam.transform.position.y - transform.position.y));
     targetRotation = Quaternion.LookRotation (mousePos - new Vector3(transform.position.x,0,transform.position.z));
     transform.eulerAngles = Vector3.up * Mathf.MoveTowardsAngle (transform.eulerAngles.y, targetRotation.eulerAngles.y, AimingSpeed ) ;
 }
开发者ID:andre1828,项目名称:Survival,代码行数:7,代码来源:Aiming.cs


示例6: GetBearingToTarget

    protected override void GetBearingToTarget(Vector3 targetPosition)
    {
        base.GetBearingToTarget(targetPosition);

        Vector3 bearingToTarget = targetPosition - transform.position;
        targetBearing = Quaternion.LookRotation(bearingToTarget);
    }
开发者ID:Blkx-Darkreaper,项目名称:Unity,代码行数:7,代码来源:TankUnit.cs


示例7: Update

    // Update is called once per frame
    void Update()
    {
        if (Target == null)return;
        //find the vector pointing from our position to the target
        _direction = (Target.position - transform.position).normalized;
        float step = RotationSpeed * Time.deltaTime;

        //create the rotation we need to be in to look at the target
        _lookRotation = Quaternion.LookRotation(_direction, Vector3.up);

        ////rotate us over time according to speed until we are in the required rotation
        //        if (Vector3.Angle (transform.rotation.eulerAngles, _lookRotation.eulerAngles) < minimumFireAngle && Target != null)
        //		{
        //			TagetAligned = true;
        //		}
        //		else
        //		{
        //			TagetAligned = false;
        //		}
        //
        //		BroadcastMessage("TagetAlignedStatus", this, SendMessageOptions.DontRequireReceiver);
        transform.rotation = Quaternion.Slerp(transform.rotation, _lookRotation, step);
        transform.localEulerAngles = new Vector3(transform.localEulerAngles.x, transform.localEulerAngles.y, 0f);
        Vector3 newDir = Vector3.RotateTowards(transform.forward, _direction, step, 0.0F);
        Debug.DrawRay(transform.position, newDir * 50, Color.red);
    }
开发者ID:SmashedCrabStudio,项目名称:Quick-Alps-Hack,代码行数:27,代码来源:lookTo.cs


示例8: Update

    // Update is called once per frame
    void Update()
    {
        // Rotate the pickup
        Quaternion q = new Quaternion();
        q.eulerAngles = new Vector3 (0, Time.time*60, Mathf.Sin (Time.time*2) * 10);

        transform.localRotation = q;

        // Check if the pickup is near one of the players
        GameObject player1 = GameObject.Find ("Player1");
        GameObject player2 = GameObject.Find ("Player2");

        if( player1 != null )
        {
            if( (player1.transform.position - this.transform.position).magnitude < 2 )
            {
                GUIManager.currentScore += 100;
                Destroy(this.gameObject);
            }

        }

        if( player2 != null )
        {
            if( (player2.transform.position - this.transform.position).magnitude < 2 )
            {
                GUIManager.currentScore += 100;
                Destroy(this.gameObject);
            }

        }
    }
开发者ID:qimmer,项目名称:mta13341,代码行数:33,代码来源:Pickup.cs


示例9: Update

 // Update is called once per frame
 void Update()
 {
     if (target != null) {
         look = Quaternion.LookRotation (target.transform.position - transform.position);
         transform.rotation = Quaternion.Slerp (transform.rotation, look, Time.deltaTime * 8.0F);
     }
 }
开发者ID:jonathan84clark,项目名称:OrbitalDebris1,代码行数:8,代码来源:FireMissile.cs


示例10: Enemy

 public Enemy(int anID, string aName, Vector3 aPos, Quaternion aRot)
 {
     base.setID(anID);
     base.setName(aName);
     position = aPos;
     rotation = aRot;
 }
开发者ID:WaterKH,项目名称:FrankensteinVendetta,代码行数:7,代码来源:Enemy.cs


示例11: LookRotation

    public void LookRotation(Transform character, Transform camera)
    {
        /*if(i >0) Check for controllers
            yRot = Input.GetAxis ("Mouse X") * XSensitivity;
            xRot = Input.GetAxis ("Mouse Y") * YSensitivity;
            }*/
            float deadzone = 0.25f;
            Vector2 stickInput = new Vector2(Input.GetAxis("Mouse Y") *YSensitivity, Input.GetAxis("Mouse X") *XSensitivity);
            if(stickInput.magnitude < deadzone)
                stickInput = Vector2.zero;
            else
                stickInput = stickInput.normalized * ((stickInput.magnitude - deadzone) / (1 - deadzone));

                m_CharacterTargetRot *= Quaternion.Euler (0f, stickInput.y, 0f);
                m_CameraTargetRot *= Quaternion.Euler (-stickInput.x, 0f, 0f);

            if (clampVerticalRotation) {
                m_CameraTargetRot = ClampRotationAroundXAxis (m_CameraTargetRot);
            }
            if(smooth)
            {
                character.localRotation = Quaternion.Slerp (character.localRotation, m_CharacterTargetRot,
                    smoothTime * Time.deltaTime);
                camera.localRotation = Quaternion.Slerp (camera.localRotation, m_CameraTargetRot,
                    smoothTime * Time.deltaTime);
            }
            else
            {
                character.localRotation = m_CharacterTargetRot;
                camera.localRotation = m_CameraTargetRot;
            }
    }
开发者ID:gsabourin,项目名称:timebanana,代码行数:32,代码来源:MouseLook.cs


示例12: PlaneEqualsTest

        public void PlaneEqualsTest()
        {
            Plane a = new Plane(1.0f, 2.0f, 3.0f, 4.0f);
            Plane b = new Plane(1.0f, 2.0f, 3.0f, 4.0f);

            // case 1: compare between same values
            object obj = b;

            bool expected = true;
            bool actual = a.Equals(obj);
            Assert.Equal(expected, actual);

            // case 2: compare between different values
            b.Normal = new Vector3(10.0f, b.Normal.Y, b.Normal.Z);

            obj = b;
            expected = false;
            actual = a.Equals(obj);
            Assert.Equal(expected, actual);

            // case 3: compare between different types.
            obj = new Quaternion();
            expected = false;
            actual = a.Equals(obj);
            Assert.Equal(expected, actual);

            // case 3: compare against null.
            obj = null;
            expected = false;
            actual = a.Equals(obj);
            Assert.Equal(expected, actual);
        }
开发者ID:jsalvadorp,项目名称:corefx,代码行数:32,代码来源:PlaneTests.cs


示例13: Start

    // Use this for initialization
    void Start()
    {
        //leftArm.transform.eulerAngles = new Vector3(0f, 0f, 90f);
        leftArmTargetRotation = Quaternion.Euler(0f, 0f, 90f);
        //leftArmTargetRotation = Quaternion.Euler(0f, 0f, 80f);
        leftArmState = 1;

        //rightArm.transform.eulerAngles = new Vector3(0f, 0f, -90f);
        rightArmTargetRotation = Quaternion.Euler(0f, 0f, -90f);
        //rightArmTargetRotation = Quaternion.Euler(0f, 0f, -80f);
        rightArmState = 1;

        //leftLeg.transform.eulerAngles = new Vector3(0f, 0f, 0f);
        leftLegTargetRotation = Quaternion.Euler(0f, 0f, 0f);
        leftLegState = 1;

        //rightLeg.transform.eulerAngles = new Vector3 (0f, 0f, 0f);
        rightLegTargetRotation = Quaternion.Euler(0f, 0f, 0f);
        rightLegState = 1;
        /*

        leftArmDown.SetActive(true);
        leftArmState = 1;

        rightArmDown.SetActive(true);
        rightArmState = 1;

        leftLegDown.SetActive (true);
        leftLegState = 1;

        rightLegDown.SetActive (true);
        rightLegState = 1;
        */
    }
开发者ID:cutedork,项目名称:YogaGameMidterm,代码行数:35,代码来源:ChangeLimbs3d.cs


示例14: OnUpdate

 protected override void OnUpdate(float factor, bool isFinished)
 {
     if (this.to != null)
     {
         if (this.mTrans == null)
         {
             this.mTrans = base.transform;
             this.mPos = this.mTrans.position;
             this.mRot = this.mTrans.rotation;
             this.mScale = this.mTrans.localScale;
         }
         if (this.from != null)
         {
             this.mTrans.position = this.from.position * (1f - factor) + this.to.position * factor;
             this.mTrans.localScale = this.from.localScale * (1f - factor) + this.to.localScale * factor;
             this.mTrans.rotation = Quaternion.Slerp(this.from.rotation, this.to.rotation, factor);
         }
         else
         {
             this.mTrans.position = this.mPos * (1f - factor) + this.to.position * factor;
             this.mTrans.localScale = this.mScale * (1f - factor) + this.to.localScale * factor;
             this.mTrans.rotation = Quaternion.Slerp(this.mRot, this.to.rotation, factor);
         }
         if (this.parentWhenFinished && isFinished)
         {
             this.mTrans.parent = this.to;
         }
     }
 }
开发者ID:GameDiffs,项目名称:TheForest,代码行数:29,代码来源:TweenTransform.cs


示例15: CreateFromQuaternion

        public static void CreateFromQuaternion(ref Quaternion quaternion, out Matrix3x3 result)
        {
            float qX2 = quaternion.X + quaternion.X;
            float qY2 = quaternion.Y + quaternion.Y;
            float qZ2 = quaternion.Z + quaternion.Z;
            float XX = qX2 * quaternion.X;
            float YY = qY2 * quaternion.Y;
            float ZZ = qZ2 * quaternion.Z;
            float XY = qX2 * quaternion.Y;
            float XZ = qX2 * quaternion.Z;
            float XW = qX2 * quaternion.W;
            float YZ = qY2 * quaternion.Z;
            float YW = qY2 * quaternion.W;
            float ZW = qZ2 * quaternion.W;

            result.X = new Vector3(
                1 - YY - ZZ,
                XY + ZW,
                XZ - YW);

            result.Y = new Vector3(
                XY - ZW,
                1 - XX - ZZ,
                YZ + XW);

            result.Z = new Vector3(
                XZ + YW,
                YZ - XW,
                1 - XX - YY);
        }
开发者ID:RossNordby,项目名称:scratchpad,代码行数:30,代码来源:Matrix3x3.cs


示例16: Fire

    /// <summary>
    /// Fires a bullet
    /// </summary>
    public void Fire(int owner, Vector3 firePosition, Quaternion fireRotation)
    {
        GameObject obj = NewObjectPooler.Get().GetPooledObject();

        if (obj == null)
        {
            Debug.LogError("Could not generate bullet from pooler");
            return;
        }

        obj.transform.position = firePosition;
        obj.transform.rotation = fireRotation;
        obj.transform.Translate(SpawnOffset);
        obj.SetActive(true);
        obj.GetComponent<Bullet>().Owner = owner;

        Vector3 bulletVelocity =
            transform.right * m_bulletSpeedForward +
            Vector3.up * m_bulletSpeedUp;

        obj.GetComponent<Rigidbody>().AddForce(bulletVelocity);

        if(PlayerManager.IsCloseToPlayer(obj.transform.position, 30.0f))
        {
            SoundManager.Get().PlaySound(SoundManager.SoundID.FIRE);
        }
    }
开发者ID:ActionAtSea,项目名称:action-at-sea,代码行数:30,代码来源:BulletFireScript.cs


示例17: GetTransform

	public override void GetTransform(PropSocket socket, DungeonModel model, Matrix4x4 propTransform, System.Random random, out Vector3 outPosition, out Quaternion outRotation, out Vector3 outScale) {
		base.GetTransform(socket, model, propTransform, random, out outPosition, out outRotation, out outScale);
		
		var angle = random.Range(0, 1) * 180;
		var rotation = Quaternion.Euler(0, angle, 0);
		outRotation = rotation;
	}
开发者ID:coderespawn,项目名称:dungeon-architect-quick-start-unity,代码行数:7,代码来源:RandomRotY90TransformRule.cs


示例18: RotateToNext

    private void RotateToNext()
    {
        // set the next texture slide
        tex = (tex + 1) % maxTextures;

        if(!isBehindUser)
        {
            side = (side + 1) % maxSides;
        }
        else
        {
            if(side <= 0)
                side = maxSides - 1;
            else
                side -= 1;
        }

        if(horizontalSides[side] && horizontalSides[side].renderer)
        {
            horizontalSides[side].renderer.material.mainTexture = slideTextures[tex];
        }

        // rotate the presentation
        float yawRotation = !isBehindUser ? 360f / maxSides : -360f / maxSides;
        Vector3 rotateDegrees = new Vector3(0f, yawRotation, 0f);
        targetRotation *= Quaternion.Euler(rotateDegrees);
        isSpinning = true;
    }
开发者ID:dannegm,项目名称:ExploraX3,代码行数:28,代码来源:PresentationScript.cs


示例19: Quaternion

 public Quaternion(Quaternion Quaternion)
 {
     X = Quaternion.X;
     Y = Quaternion.Y;
     Z = Quaternion.Z;
     W = Quaternion.W;
 }
开发者ID:baldercollaborator,项目名称:Balder,代码行数:7,代码来源:Quaternion.cs


示例20: Event

 public Event(Vector3 cpos, Quaternion rot, Interactable interact, bool hasInteracted)
 {
     position = cpos;
     interactable = interact;
     rotation = rot;
     this.hasInteracted = hasInteracted;
 }
开发者ID:PaulMilla,项目名称:2Dcapstone,代码行数:7,代码来源:Event.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# QueriableDummy类代码示例发布时间:2022-05-24
下一篇:
C# Quat类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap