More than 3 years have passed since last update.
角度取得
transform.localEulerAngles.z;
上下左右に押す力
GetComponent<Rigidbody2D> ().velocity.y; // 上下
GetComponent<Rigidbody2D> ().velocity.x; // 左右
指定角度&指定スピードで大砲みたいに飛ばす
Vector2 v;
v.x = Mathf.Cos(Mathf.Deg2Rad * direction) * speed;
v.y = Mathf.Sin(Mathf.Deg2Rad * direction) * speed;
GetComponent<Rigidbody2D>().velocity = v;
速度や重力のスピード制限に、全方向の速度取得
GetComponent<Rigidbody2D> ().velocity.magnitude
速度方向取得(移動量が大きい角度を取得)
dirVelocity = Mathf.Atan2 (GetComponent<Rigidbody2D>().velocity.y, GetComponent<Rigidbody2D>().velocity.x) * Mathf.Rad2Deg;
回転させないように固定など。
GetComponent<Rigidbody2D> ().constraints = RigidbodyConstraints2D.FreezeRotation; // 回転させないように、zだけ固定
GetComponent<Rigidbody2D> ().constraints = RigidbodyConstraints2D.FreezePosition; // x,y,z 全て固定
GetComponent<Rigidbody2D> ().constraints = RigidbodyConstraints2D.None; // x,y,zの固定解除

げーむくりえいたー。
顔は濃いが存在の薄さに悩んでいる。
無敵のエンジニアに出会いたい。
書籍「仕事はたのしいかね」の、大きな事でも試してみればの精神に感銘を受けている。
好きな言葉:好きこそものの上手なれ / 楽は苦の種、苦は楽の種
https://matsudapress.comWhy not register and get more from Qiita?
- We will deliver articles that match you
By following users and tags, you can catch up information on technical fields that you are interested in as a whole
- you can read useful information later efficiently
By "stocking" the articles you like, you can search right away
Sign upLogin