Version: 5.3 (switch to 5.4b)
言語English
  • C#
  • JS

スクリプト言語

好きな言語を選択してください。選択した言語でスクリプトコードが表示されます。

HingeJoint.motor

マニュアルに切り替える
public JointMotor motor;

説明

モーター( Motor )により角度/秒が設定された速度となるように力を加えます。

モーターは JointMotor.targetVelocity で設定された角度/秒単位の角速度に到達しようとします。 モーターは JointMotor.force が十分な大きさである場合にかぎり targetVelocity に到達できます。 もしジョイントが targetVelocity より速く回転するとモーターは壊れます。 負の値の targetVelocity によりモーターは反対方向に回転します。

モーターが出力できる最大のトルクが force です。0 の場合、モーターは無効化されます。

モーターは JointMotor.freeSpin が false の場合にかぎり targetVelocity より速く回転すると壊れます。 もし freeSpin が true の場合、モーターは壊れません。

See Also: useMotor, JointMotor.

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void Start() { HingeJoint hinge = GetComponent<HingeJoint>(); JointMotor motor = hinge.motor; motor.force = 100; motor.targetVelocity = 90; motor.freeSpin = false; hinge.motor = motor; hinge.useMotor = true; } }

モーターを変更しても、モーターは自動的に有効化されません。

spring が有効になっている場合、motor を有効にすると springオーバーライド します。motor を再び無効にした場合、spring が有効になります。