当前位置: 首页>>代码示例>>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;未经允许,请勿转载。