言語: 日本語
  • C#
  • JS
  • Boo

スクリプト言語

お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。

Rigidbody.AddForceAtPosition

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Switch to Manual
public function AddForceAtPosition(force: Vector3, position: Vector3, mode: ForceMode = ForceMode.Force): void;
public void AddForceAtPosition(Vector3 force, Vector3 position, ForceMode mode = ForceMode.Force);
public def AddForceAtPosition(force as Vector3, position as Vector3, mode as ForceMode = ForceMode.Force) as void

Description

特定の位置から力を適用します。結果、これはトルクを適用しオブジェクトに力を加えます

リアルな効果を実現するために position は rigidbody 表面の範囲内にほぼ収まっているべきです。 これは、爆発を表現する際には最も一般的に使用されます。爆発を適用する時には、一度だけではなく、複数回適用するのが一番良いでしょう。 /position/ が Rigidbody の中心から離れている際は適用される回転運動が非現実的に大きなものになることに注意して下さい。

	function ApplyForce (body : Rigidbody) {
		var direction : Vector3 = body.transform.position - transform.position;
		body.AddForceAtPosition(direction.normalized, transform.position);
	}
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    void ApplyForce(Rigidbody body) {
        Vector3 direction = body.transform.position - transform.position;
        body.AddForceAtPosition(direction.normalized, transform.position);
    }
}
import UnityEngine
import System.Collections

public class ExampleClass(MonoBehaviour):

	def ApplyForce(body as Rigidbody) as void:
		direction as Vector3 = (body.transform.position - transform.position)
		body.AddForceAtPosition(direction.normalized, transform.position)