Skip to content
All gists
Back to GitHub
Sign in
Sign up
Sign in
Sign up
{{ message }}
Instantly share code, notes, and snippets.
matsuyoro
/
file0.txt
Last active
Apr 11, 2016
Star
0
Fork
0
Star
Code
Revisions
3
Embed
What would you like to do?
Embed
Embed this gist in your website.
Share
Copy sharable link for this gist.
Clone via HTTPS
Clone with Git or checkout with SVN using the repository’s web address.
Learn more about clone URLs
Download ZIP
Unity rigidbody2Dでよく使うメソッド一覧 ref:
http://qiita.com/matsuyoro/items/e32b4fd12d20e5c06614
Raw
file0.txt
transform.localEulerAngles.z;
Raw
file1.txt
GetComponent<Rigidbody2D> ().velocity.y; // 上下
GetComponent<Rigidbody2D> ().velocity.x; // 左右
Raw
file2.txt
Vector2 v;
v.x = Mathf.Cos(Mathf.Deg2Rad * direction) * speed;
v.y = Mathf.Sin(Mathf.Deg2Rad * direction) * speed;
GetComponent<Rigidbody2D>().velocity = v;
Raw
file3.txt
GetComponent<Rigidbody2D> ().velocity.magnitude
Raw
file4.txt
dirVelocity = Mathf.Atan2 (GetComponent<Rigidbody2D>().velocity.y, GetComponent<Rigidbody2D>().velocity.x) * Mathf.Rad2Deg;
Raw
file5.txt
GetComponent<Rigidbody2D> ().constraints = RigidbodyConstraints2D.FreezeRotation; // 回転させないように、zだけ固定
GetComponent<Rigidbody2D> ().constraints = RigidbodyConstraints2D.FreezePosition; // x,y,z 全て固定
Raw
file6.txt
GetComponent<Rigidbody2D> ().constraints = RigidbodyConstraints2D.None; // x,y,zの固定解除
Sign up for free
to join this conversation on GitHub
. Already have an account?
Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.