Created
January 12, 2015 08:15
-
-
Save kazuooooo/89c2e4e71c574689d823 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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