| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | using System.Collections; using System.Collections.Generic; using UnityEngine; public class PaddleScript : MonoBehaviour {     private Vector3 mouse; //マウスカーソルの位置     private Vector3 paddle; //パドルの位置     void Update()     {         mouse = Input.mousePosition; //マウスカーソルの位置を取得         //マウスカーソルのスクリーン座標をワールド座標に変換して、paddleに入れる         paddle = Camera.main.ScreenToWorldPoint(new Vector3(mouse.x, mouse.y, 10));         paddle.x = Mathf.Clamp(paddle.x, -4.2f, 4.2f); //Xの移動範囲         paddle.y = -2; //Yの位置を固定         this.transform.position = paddle; //パドルの位置を更新     } } | 
 
         
         
           
         
           
        