2ちゃんねる ■掲示板に戻る■ 全部 1- 最新50    

■ このスレッドは過去ログ倉庫に格納されています

【3Dゲームエンジン】Unity質問スレッド22

879 :名前は開発中のものです。:2016/02/27(土) 02:23:52.28 ID:fKTTe1am.net
2Dのジャンプアクションを作ってるのですが、2つほど質問があります
@移動中にジャンプができない、ジャンプ中に動くとグラインド?ホバリング?する
APlayerに空の子オブジェクト付けてPhysics2D.Linecastで接地判定を行いたいが子オブジェクトの座標が取れない
初歩的なものだとは思いますが知恵をお貸しください。以下プレイヤーのソースコード

public float kickPower=0;//移動とジャンプの距離
public LayerMask Check;//接地判定で判定するためのレイヤーを取得
private bool GROUNDCHECK = false;

// Use this for initialization

 void Start () {
}// Update is called once per frame

 void Update ()
{//jump処理
GROUNDCHECK = Physics2D.Linecast(transform.position,transform.position*-1, Check);//ここの2つ目の引数で子オブジェクトの座標を呼びたい
if (GROUNDCHECK)
{ if (Input.GetButtonDown("Jump")){
GetComponent<Rigidbody2D>().velocity = Vector2.up * kickPower;}
}
//右へ移動
if (Input.GetButton("move_R")){
GetComponent<Rigidbody2D>().velocity = Vector2.right * kickPower;
}
//左へ移動
if (Input.GetButton("move_L")){
GetComponent<Rigidbody2D>().velocity = Vector2.left * kickPower;
}
}

総レス数 1004
325 KB
新着レスの表示

掲示板に戻る 全部 前100 次100 最新50
read.cgi ver.24052200