LoginSignup
6
2

More than 5 years have passed since last update.

unity > 物体が別の物体にぶつかったらくっつくようにする (反発しないようにする)

Last updated at Posted at 2015-08-08
動作確認
Unity 5.1.1-f on Mac OSX 10.8.5

物体が別の物体にぶつかった時、massやAddForceされた力により反発をしてしまう。
反発ではなく、その物体にくっつくようにするには、ぶつかる物体に以下のスクリプトをつける。

ぶつかった時点でisKinematicをセットしている。

SphereControl.cs
using UnityEngine;
using System.Collections;

public class SphereControl : MonoBehaviour {

    void Update () {
    }

    void OnCollisionEnter(Collision col)
    {
        Rigidbody rb = gameObject.GetComponent<Rigidbody> ();
        rb.isKinematic = true;
    }
}
6
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
2