Skip to content

Instantly share code, notes, and snippets.

@kazuooooo
Created January 12, 2015 08:15
Show Gist options
  • Save kazuooooo/89c2e4e71c574689d823 to your computer and use it in GitHub Desktop.
Save kazuooooo/89c2e4e71c574689d823 to your computer and use it in GitHub Desktop.
public float pram;
void OnCollisionEnter(Collision collision){
if (collision.gameObject.tag == "Player") {
//弾の速度を取得
Vector3 v = rigidbody.velocity;
Debug.Log (v);
//加力
float x = v.x * pram;
float y = v.y * pram;
float z = v.z * pram;
//ぶつかったオブジェクトに力を加える
collision.gameObject.rigidbody.AddForce (x, y, z);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment