【ゲームエンジン】Unityなんでも質問スレpart11at GAMEDEV
【ゲームエンジン】Unityなんでも質問スレpart11 - 暇つぶし2ch513:; void Update() { if(Input.GetMouseButton(0)) { //triangle.transform.position = camera.main.screentoworldpoint(input.mouseposition) // + new vector3(0, 0, 10); getObject().transform.position = Camera.main.ScreenToWorldPoint(Input.mousePosition) + new Vector3(0, 0, 10); } } GameObject getObject() { //クリックされたゲームオブジェクト clickedObject = null; //レイキャストの始点と終点を決定 ,vector2 Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); //ここでレイを飛ばす RaycastHit2D hit = Physics2D.Raycast(ray.origin, ray.direction); if (hit) { clickedObject = hit.transform.gameObject; } return clickedObject; } }




次ページ
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch