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


C# Rigidbody.MovePosition方法代码示例

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


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

示例1: pullObject

    private IEnumerator pullObject(Rigidbody collidedRigidbody)
    {
        while(Vector3.Distance(transform.parent.position, collidedRigidbody.transform.position) > 1.5f)
        {
            pullTimer -= Time.deltaTime;

            if(pullTimer < 0)
            {
                yield return new WaitForSeconds(0.333f);
                pullTimer = resetPullTimer;
            }
            else
            {
                collidedRigidbody.MovePosition(collidedRigidbody.transform.position + Vector3.up * pullSpeed * Time.deltaTime);
                yield return null;
            }
        }

        //reach top now make fall
        if (collidedRigidbody.gameObject.tag != "Player")
        {
            collidedRigidbody.AddForce(Vector3.right * 10, ForceMode.Impulse);
        }
        //		else
        //		{
        //			//atTop = true;
        //		}
    }
开发者ID:TamDu-au,项目名称:HL3Confirmed,代码行数:28,代码来源:BarnaclePull.cs

示例2: Start

	void Start () 
	{
		rb3d = GetComponent<Rigidbody> ();	

		//Set startup position
		rb3d.MovePosition(new Vector3(0.0f, playerAboveLevel, 0.0f));
	}
开发者ID:jrosco,项目名称:unity-scripts,代码行数:7,代码来源:PlayerController.cs

示例3: Grab

    void Grab(Rigidbody rb)
    {
        rb.isKinematic = false;
        isGrapped = true;
        rb.MovePosition(hand.transform.position);
        rb.velocity = Vector3.zero;
        hj.connectedBody = rb;

        rb.GetComponent<Item>().checkIfKaverit();
    }
开发者ID:kersseliM,项目名称:syysjamit2015,代码行数:10,代码来源:Grapper.cs

示例4: Start

    void Start()
    {
        Vector3 tangent = Vector3.zero;
        int kn = 0;

        rb = GetComponent<Rigidbody>();
        Vector3 p = transform.position;
        Vector3 np = path.FindNearestPointWorld(p, 5, ref kn, ref tangent, ref alpha);
        rb.MovePosition(np);
    }
开发者ID:Morac,项目名称:Orca6,代码行数:10,代码来源:MegaShapeRBodyPath.cs

示例5: Awake

        private void Awake()
        {
            _transform = transform;
            _rigidbody = GetComponent<Rigidbody>();

            this.UpdateAsObservable()
                .Select(_ => new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")))
                .Subscribe(axis =>
                {
                    Vector3 currentPos = _transform.position;
                    currentPos += axis * Time.smoothDeltaTime * speed;
                    _rigidbody.MovePosition(currentPos);
                });
        }
开发者ID:ppugend,项目名称:UniBt,代码行数:14,代码来源:PlayerMovement.cs

示例6: Update

    void Update()
    {
        Vector3 temp = transform.position;
        temp.y = 0f;
        transform.position = temp;

        screenPos = Camera.main.WorldToScreenPoint(transform.position);
        foreach (multi.MultiplayerHandler.PlayerData data in clientServer.multiplayerHandler.playerDB) {
            if (data.name == name) {
                body = gameObject.GetComponent<Rigidbody> ();
                body.MovePosition (new Vector3 ((float)data.posX, (float)data.posY, (float)data.posZ));

                //body.MoveRotation (new Quaternion (0f, (float)clientServer.multiplayerHandler.recD, 0f, 0f));

                Quaternion rot = new Quaternion ();
                rot.eulerAngles = new Vector3 (0, (float)data.angleY, 0);
                gameObject.transform.rotation = rot;
                gameObject.GetComponent<Animator> ().SetBool ("IsWalking", data.IsWalking);
                gameObject.GetComponentInChildren<GunAnimation> ().isShooting = data.IsShooting;             }
        }
    }
开发者ID:sea1and,项目名称:SurvivalGame,代码行数:21,代码来源:BodyScript.cs

示例7: Start

 // Use this for initialization
 void Start()
 {
     RigidPlayer = GetComponent<Rigidbody>();
     RigidPlayer.MovePosition (Middle.transform.position);
     pos = 2;
 }
开发者ID:Haorou,项目名称:quadriction,代码行数:7,代码来源:playerController.cs

示例8: Receive

 //    void Receive(Transform warpee)
 //    {
 //        float yPosition = warpee.position.y;
 ////		warpee.position = new Vector3(transform.position.x, yPosition, transform.position.z);
 ////		warpee.position = new Vector3(spawn.position.x, yPosition, spawn.position.z);
 //
 //
 //
 ////		warpee.GetComponent<NavMeshAgent>().ResetPath();
 ////		warpee.position = new Vector3(spawn.position.x, yPosition, spawn.position.z);
 //        warpee.GetComponent<NavMeshAgent>().Warp(new Vector3(spawn.position.x, yPosition, spawn.position.z));
 //    }
 //
 //    void Send(Transform warpee)
 //    {
 //        destination.Receive(warpee);
 //    }
 void Receive(Rigidbody body)
 {
     float yPosition = body.position.y;
     body.position = new Vector3(transform.position.x, yPosition, transform.position.z);
     body.MovePosition(new Vector3(spawn.position.x, yPosition, spawn.position.z));
 }
开发者ID:ajanzen,项目名称:minibump,代码行数:23,代码来源:Warp.cs

示例9: Update

    void Update() {
        if(nIdentity == null) return;

        if (doubleScore == true) {
            doubleScoreTime -= Time.deltaTime;
            if (doubleScoreTime <= 0)
            {
                doubleScore = false;
                doubleScoreTime = doubleScoreTimeInit;
            }
        }

        if (fasterFire == true) {
            fasterFireTime -= Time.deltaTime;
            if (fasterFireTime <= 0)
            {
                fasterFire = false;
                fasterFireTime = fasterFireTimeInit; //Resets timer
                currentFireRate = fireRate; //Resets fire rate to classic fire rate. Only needed for local-viewing
            }
        }

        if (shielded == true) {
            shieldedTime -= Time.deltaTime;
            if (shieldedTime <= 0) {
                shielded = false;
                shield.SetActive(false);
                Destroy(shield);
                shieldedTime = fasterFireTimeInit; //Resets timer
            }
        }
        if (!nIdentity.isLocalPlayer) return;

        rb = GetComponent<Rigidbody>();
        Vector3 forward = transform.forward;
        Vector3 right = transform.right;
#if UNITY_ANDROID
        float aimH = CrossPlatformInputManager.GetAxis ("AimH");
        float aimV = CrossPlatformInputManager.GetAxis ("AimV");
        float moveV = CrossPlatformInputManager.GetAxis("MoveV");
        float moveH = CrossPlatformInputManager.GetAxis("MoveH");
#endif

#if UNITY_STANDALONE
        float aimH = (-(Input.GetKey("left") ? 1 : 0) + (Input.GetKey("right") ? 1 : 0));
        float aimV = ((Input.GetKey("up") ? 1 : 0) - (Input.GetKey("down") ? 1 : 0));
        float moveV = ((Input.GetKey("w") ? 1 : 0) - (Input.GetKey("s") ? 1 : 0));
        float moveH = (-(Input.GetKey("a") ? 1 : 0) + (Input.GetKey("d") ? 1 : 0));
#endif

        lastMoveH = moveH;
        lastMoveV = moveV;

        if (needsReflection && invertControls) {
            Vector3 refMove = reflectPoint(moveH, moveV);
            Vector3 refAim = reflectPoint(aimH, aimV);

            moveH = refMove[0];
            moveV = refMove[1];
            aimH = refAim[0];
            aimV = refAim[1];
        }

        float forwardSpeed = speed * moveV;
        float strafeSpeed = speed * moveH;

        Vector3 moveDir = forwardSpeed * forward + strafeSpeed * right;
        Vector3 turretDirection = ((forward * aimV) + (right * aimH)).normalized;
        rotateObject(turret, turretDirection);
        Vector3 worldPos = obsCamera.position + obsCamera.parent.transform.position;
        Vector3 newLocation = transform.position + moveDir * Time.deltaTime * 5;
        float distPlanetToCam = Vector3.Distance(planetCenter, worldPos);
        float distPlayerToCam = Vector3.Distance(newLocation, worldPos);
        rotateObject(model, moveDir.normalized);
        rb.MovePosition(newLocation);

    }
开发者ID:Geor23,项目名称:Planets,代码行数:77,代码来源:PlayerControllerMobile.cs


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