當前位置: 首頁>>代碼示例>>C#>>正文


C# Rigidbody.AddRelativeTorque方法代碼示例

本文整理匯總了C#中UnityEngine.Rigidbody.AddRelativeTorque方法的典型用法代碼示例。如果您正苦於以下問題:C# Rigidbody.AddRelativeTorque方法的具體用法?C# Rigidbody.AddRelativeTorque怎麽用?C# Rigidbody.AddRelativeTorque使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在UnityEngine.Rigidbody的用法示例。


在下文中一共展示了Rigidbody.AddRelativeTorque方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Start

	// Use this for initialization
	void Start () {
//        gameController = GameControllerSingleton.get();
        rb = GetComponent<Rigidbody>();
        rb.AddRelativeTorque(0, initTorque, 0);
        rb.AddRelativeForce(0, initYForce, 0);
        initY = transform.position.y;
	}
開發者ID:rawrimryno,項目名稱:Zambio,代碼行數:8,代碼來源:PowerUpScript.cs

示例2: applyAngularForce

 public void applyAngularForce(Rigidbody toBody, Vector3 desiredTorque, bool relative)
 {
     if(relative) {
         toBody.AddRelativeTorque(desiredTorque, this.angularForceMode);
     }
     else {
         toBody.AddTorque(desiredTorque, this.angularForceMode);
     }
 }
開發者ID:rusticgames,項目名稱:rts,代碼行數:9,代碼來源:Mechanism.cs

示例3: Start

	// Use this for initialization
	void Start () {
		rb = GetComponent<Rigidbody>();
		
		rb.velocity = new Vector2(Random.Range(-maxSpeed, maxSpeed), Random.Range(-maxSpeed, maxSpeed));
		rb.AddRelativeTorque(Random.Range(0.0f, maxRotation), Random.Range(0.0f, maxRotation), Random.Range(0.0f, maxRotation));
		transform.localScale = new Vector3(Random.Range(minScale, maxScale), Random.Range(minScale, maxScale), Random.Range(minScale, maxScale));
		
		rb.mass = rb.mass * transform.localScale.x * transform.localScale.y * transform.localScale.z;
	}
開發者ID:rymotion,項目名稱:hackpoly_game,代碼行數:10,代碼來源:Asteroid.cs

示例4: Start

	// Use this for initialization
	void Start ()
    {
        //Start spinning
        rb = GetComponent<Rigidbody>();
        //Spinning might be random on some, could be fixed, use a bool to decide which behaviour to use
        if(randomSpin)
        {
            spinDir = new Vector3(Random.Range(0, 2), Random.Range(0, 2), Random.Range(0, 2)).normalized;
            spinForce = Random.Range(10, 100);
        }
        rb.AddRelativeTorque(spinDir * spinForce * Time.smoothDeltaTime);
    }
開發者ID:AetherAlchemistEW,項目名稱:CameraProject,代碼行數:13,代碼來源:Asteroid.cs

示例5: Awake

        public void Awake()
        {
            BallRb = GetComponent<Rigidbody>();
            //BallRb.useGravity = false;
            //BallRb.AddRelativeForce(Vector3.one * 500);
            if (startSpeed == 0)
                startSpeed = -15.0f;
            BallRb.maxAngularVelocity = maxAngularSpeed;
            BallRb.AddRelativeTorque(Vector3.one);
            BallRb.velocity = new Vector3(0, startSpeed, 0);
            grav = new Vector3(0, -9.81f, 0);

            playerContact = GameObject.FindGameObjectWithTag("Player").GetComponent<PaddleContact>();
            enemyContact = GameObject.FindGameObjectWithTag("Enemy").GetComponent<PaddleContact>();

            playerContact.ball = this;
            enemyContact.ball = this;

            ballAudio = GetComponent<AudioSource>() as AudioSource;
        }
開發者ID:joouur,項目名稱:3DPONG,代碼行數:20,代碼來源:Ball.cs

示例6: EjectShell

	/// <summary>
	/// spawns the 'ShellPrefab' gameobject and gives it a velocity
	/// </summary>
	protected virtual void EjectShell()
	{

		if (ShellPrefab == null)
			return;

		// spawn the shell
		GameObject s = null;

		s = (GameObject)vp_Utility.Instantiate(ShellPrefab,
			((m_ShellEjectSpawnPoint == null)
			? FirePosition + m_ProjectileSpawnPoint.transform.TransformDirection(ShellEjectPosition)	// we have no shell eject object: use old logic
			: m_ShellEjectSpawnPoint.transform.position)												// we have a shell eject object: use new logic
			, m_ProjectileSpawnPoint.transform.rotation);

		s.transform.localScale = m_ActualShellScale;
		vp_Layer.Set(s.gameObject, vp_Layer.Debris);

		// send it flying
		m_ShellRigidbody = s.GetComponent<Rigidbody>();
		if (m_ShellRigidbody == null)
			return;
			
		Vector3 force = ((m_ShellEjectSpawnPoint == null) ?
		transform.TransformDirection(ShellEjectDirection).normalized * ShellEjectVelocity	// we have a shell eject object: use new logic
		: m_ShellEjectSpawnPoint.transform.forward.normalized * ShellEjectVelocity);		// we have no shell eject object: use old logic

		// toss the shell
		m_ShellRigidbody.AddForce(force, ForceMode.Impulse);
		
		// make the shell inherit the current speed of the controller (if any)
		if (m_CharacterController)	// TODO: should use a velocity calculated from operator transform
		{

			Vector3 velocityForce = (m_CharacterController.velocity);
			m_ShellRigidbody.AddForce(velocityForce, ForceMode.VelocityChange);

		}

		// add random spin if user-defined
		if (ShellEjectSpin > 0.0f)
		{
			if (Random.value > 0.5f)
				m_ShellRigidbody.AddRelativeTorque(-Random.rotation.eulerAngles * ShellEjectSpin);
			else
				m_ShellRigidbody.AddRelativeTorque(Random.rotation.eulerAngles * ShellEjectSpin);
		}

	}
開發者ID:BHD7,項目名稱:Ghost_Town_FPS_Zombies,代碼行數:52,代碼來源:vp_Shooter.cs

示例7: ApplyForce

 /// <summary>
 /// Applies the force.
 /// </summary>
 /// <param name="body">The body.</param>
 public override void ApplyForce(Rigidbody body) {
   var torqueVector = Random.insideUnitSphere * Amount;
   body.AddRelativeTorque(torqueVector, ForceMode.Impulse);
 }
開發者ID:MaTriXy,項目名稱:cardboard-unity,代碼行數:8,代碼來源:RandomTorqueExplosion.cs


注:本文中的UnityEngine.Rigidbody.AddRelativeTorque方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。