當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。