【ゲームエンジン】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