1 / 63

Tennis Game Using Kinect

Tennis Game Using Kinect. Member: 施立宸 , 李少宏 , 吳品頡 , 高顗泓 指導教授 : 連震杰 老師. Outline. 1. Introduction ( 施立宸 ) 2. Kinect System Setup and Diagram, and Software Tools 2.1 Hardware: Kinect ( 施立宸 ) 2.2 Software Tools: OpenNI ( 施立宸 ) 2.3 Software Tools: 3Ds MAX ( 高顗泓 , 吳品頡 )

yorick
Télécharger la présentation

Tennis Game Using Kinect

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Tennis Game Using Kinect Member: 施立宸,李少宏,吳品頡,高顗泓 指導教授: 連震杰 老師

  2. Outline 1. Introduction (施立宸) 2. Kinect System Setup and Diagram, and Software Tools 2.1 Hardware: Kinect (施立宸) 2.2 Software Tools: OpenNI(施立宸) 2.3 Software Tools: 3Ds MAX (高顗泓,吳品頡) 2.4 Software Tools: Unity & Package(施立宸,李少宏) 2.4.1 Software Tools: Unity3D(李少ˋ宏) 2.4.2 Software Tools: Unity Wrapper(施立宸) 3. Kinect Preprocessing Using OpenNI, 3Ds Max and Unity3D (施立宸,李少宏,吳品頡 ,高顗泓) 3.1 Depth Map and Color Image Creation Using OpenNI to Process the Kinect (吳品頡 ,高顗泓) 3.2 Human Body Calibration for Skeleton Creation Using OpenNI(施立宸,李少宏) 3.3 Animated Object Component Creation Using 3Ds Max and Save to Unity3D (吳品頡,高顗泓,李少宏) 4. Right Hand Point and Skeleton Tracking Using OpenNI(施立宸) 5. Tennis Game Interaction between Human Motion and Animated Object Components 5.1 匯入.fbx並將匯入物件加入物理性質與程式 (李少宏) 5.2 網球場地設定 (李少宏) 5.3 玩家與遊戲間互動 (李少宏,施立宸) 6. Animated Tennis Game Display(李少宏,施立宸) 7. Schedule 8. Reference

  3. 1. Introduction (1/2) • Background • Motion game: Can detect our motion and give interaction. • Usually be used on sport game. • Motivation • We want to create a game in PC but use Xbox360’s Kinect. • We want to play game with more “real”. • Because I want to play with Aggassi. PC XBOX360

  4. 1. Introduction (2/2) • Example IR Light Source CMOS Sensor Receiver Skeleton analyze 可將玩家位置轉換成遊戲中人物的位置,並且支援動作判定 的網球遊戲

  5. 2. Kinect System Setup and Diagram, and Software Tools – Kinect System Setup 1. Depth Map and Color Image Creation Using OpenNI RGB + Depth Image IR Light Source Scene CMOS Sensor Receiver PS1080 SoC Kinect Light Coding USB 4. Display on Screen 3. Interaction Algorithm 2. Skeleton Extraction Using OpenNI Display recognized action Skeleton Feature Extraction Tennis Game Interaction Skeleton Feature Human Gesture Recognition PC

  6. 2. Kinect System Setup and Diagram, and Software Tools – Kinect System Diagram (1/2) 校正後的 RGB Image Depth Map 0.2 Human Body Calibration for Skeleton Creation Using OpenNI Use and to Calibration 0.1 Depth Map and Color Image Creation Using OpenNI to Process Kinect 1.0 Right Hand Point and Skeleton Tracking Using OpenNI 偵測與追蹤torso(玩家正中心)和right hand關節點 輸出, RGB Image Depth Map t>1 t=1 Update , to Unity in any time. 0.3 Animated Object Component Creation Using 3Ds MAX and Save to Unity3D 2.0 Tennis Game Interaction between Human Motion and Animated Object Components in Unity3D t>1 2.1 匯入.fbx並將匯入物件加入物理性質與程式 物理性質與參數設定 加入script(Unity中的程式碼) 2.2 網球場地設定 球場材質貼上 光線設定 加入script Ball.fbx , Racket.fbx, Player.fbx, etc. 球場與周圍環境 網球、球拍等….. 2.3 玩家與遊戲間互動 玩家回擊 動作判定 位置轉換 發球 給予球初速 動作判斷 規則、碰撞與分數判定 AI回擊 位置移動 揮拍時間判定 t=0 : 球的速度 : 球的位置 Display

  7. 2. Kinect System Setup and Diagram, and Software Tools – Kinect System Diagram (2/2) 3.0 Animated Tennis Game Display in Unity3D 我們將每個物件的位置交給Unity去做繪圖動作,並透過script來˙完成物件互動並顯示

  8. 2. Kinect System Setup and Diagram, and Software Tools – Software Tools (1/2) 1) Kinect Driver: OPENNI • Connect Kinect to PC. • Can catch skeleton joint point. 2) 3D graphic tool: 3Ds Max • Game engine can’t draw too delicate graph, so use graph drawing software. • Have many exported file types such as .fbx. • Can match many software like Unity and XNA. 3)Game Engine& Package 3.1) Game Engine: Unity3D • Implement physics, light, polygon and GUI. • Connect game engine and Kinect. 3.2)Package of Game Engine: UnityWrapper • Bind Unity3D and OPENNI. • Have many binding examples to use.

  9. 2. Kinect System Setup and Diagram, and Software Tools – Software Tools (2/2) 2) Animated Object Component Creation Using 3Ds MAX and Save to Unity3D Draw 3D objects Export .fbx .fbx file 3) Tennis Game Interaction between Human Motion and Animated Object Components in Unity3D Load UnityWrapper Write script to move component. Connect Kinect Load .fbx complete start 1) Right Hand Point and Skeleton Tracking Using OpenNI joint points 3D depth map Kinect driver Get joint points Initialize Kinect

  10. 2.1 Hardware: Kinect (1/3) • Kinect介紹 • 屬於Xbox360的裝置,Microsoft的產品 • 若使用OpenNI或MicrosoftSDK,即可運用於PC • 可蒐集彩色影像、3D深度影像、以及聲音訊號

  11. 2.1 Hardware: Kinect (2/3) • 運作原理 • 中間的鏡頭為RGB彩色攝影機 • 左右兩邊鏡頭則分別為紅外線發射器和紅外線CMOS攝影機所構成的3D深度感應器 • 內建陣列式麥克風系統

  12. 2.1 Hardware: Kinect– Spec. (3/3) • Sensor • Colour and depth-sensing lenses • Voice microphone array • Tilt motor for sensor adjustment • Fully compatible with existing Xbox 360 consoles • Field of View • Horizontal field of view: 57 degrees • Vertical field of view: 43 degrees • Physical tilt range: ± 27 degrees • Depth sensor range: 1.2m – 3.5m • Data Streams • 320×240 16-bit depth @ 30 frames/sec • 640×480 32-bit colour@ 30 frames/sec • 16-bit audio @ 16 kHz • Skeletal Tracking System • Tracks up to 6 people, including 2 active players • Tracks 20 joints per active player • Ability to map active players to Live Avatars • Audio System • Live party chat and in-game voice chat (requires Xbox Live Gold Membership) • Echo cancellation system enhances voice input • Speech recognition in multiple

  13. 2.2 Software Tools: OpenNI (1/2) • OpenNI Introduction • Certify and promote the compatibility of Natural Interaction (NI) devices, applications and middleware. • Architecture

  14. 2.2 Software Tools: OpenNI (2/2) • OpenNIvsMicrosoftSDK • 目前微軟也有自己的tool kit-- MicrosoftSDK.

  15. 2.3 Software Tools: 3Ds MAX • 3Ds MAX Introduction • A modeling, animation and rendering package. • It has modeling capabilities, a flexible plugin architecture. • Application • Video game developers • TV commercial studios • Movie effects • Movie pre-visualization

  16. 2.4 Software Tools: Unity & Package • We introduce Unity and its package.

  17. 2.4.1 Software Tools: Unity3D • Unity introduction • An integrated authoring tool for creating 3D video games. • Features • Can use C# and java. • Has its compiler environment • Easy to use.

  18. 2.4.2 Software Tools: Unity Wrapper • Unity Wrapper introduction • 可以使Unity能提取OpenNI資料的Package • Package: 一種可將Unity應用軟體包裝化的軟件 • 有許多不同版本 • We use Zigfuversion. • 使用方面較為流暢 30 fps • 有附較為完整的說明 • 軟體更新速度快 • 問題較少

  19. 3. Kinect Preprocessing Using OpenNI, 3Ds Max and Unity3D 校正後的 RGB Image Depth Map 0.2 Human Body Calibration for Skeleton Creation Using OpenNI Use and to Calibration 0.1 Depth Map and Color Image Creation Using OpenNI to Process Kinect 1.0 Right Hand Point and Skeleton Tracking Using OpenNI 偵測與追蹤torso(玩家正中心)和right hand關節點 輸出, RGB Image Depth Map t>1 t=1 Update , to Unity in any time. 0.3 Animated Object Component Creation Using 3Ds MAX and Save to Unity3D 2.0 Tennis Game Interaction between Human Motion and Animated Object Components in Unity3D t>1 2.1 匯入.fbx並將匯入物件加入物理性質與程式 物理性質與參數設定 加入script(Unity中的程式碼) 2.2 網球場地設定 球場材質貼上 光線設定 加入script Ball.fbx , Racket.fbx, Player.fbx, etc. 球場與周圍環境 網球、球拍等….. 2.3 玩家與遊戲間互動 玩家回擊 動作判定 位置轉換 發球 給予球初速 動作判斷 規則、碰撞與分數判定 AI回擊 位置移動 揮拍時間判定 t=0 : 球的速度 : 球的位置 Display

  20. 3.1 Depth Map and Color Image Creation Using OpenNI to Process the KinectKinect with OpenNI • OpenNI • 可做為driver驅動Kinect並獲得彩色圖與深度圖 • 除負責溝通硬體外,尚可透過中介軟體進行更 進一步操作,獲取更進階資訊。 • We use two class handpoint_controll() and OpenNISkeleton(),當被使用時,系統會連絡OpenNI並且從Kinect中獲取深度圖與彩色圖

  21. 3.2 Human Body Calibration for Skeleton Creation Using OpenNI • Why Calibration? • 初始化骨架 • 使分析更精準 • 所有OpenNI的function都需要校正後(僅需一次) 才能使用 • Calibration • 需要擺出T pose • 系統校正成功後便會顯示骨架

  22. 3.3 Animated Object Component Creation Using 3Ds Max and Save to Unity3D(1/8) 校正後的 RGB Image Depth Map 0.2 Human Body Calibration for Skeleton Creation Using OpenNI Use and to Calibration 0.1 Depth Map and Color Image Creation Using OpenNI to Process Kinect 1.0 Right Hand Point and Skeleton Tracking Using OpenNI 偵測與追蹤torso(玩家正中心)和right hand關節點 輸出, RGB Image Depth Map t>1 t=1 Update , to Unity in any time. 0.3 Animated Object Component Creation Using 3Ds MAX and Save to Unity3D 2.0 Tennis Game Interaction between Human Motion and Animated Object Components in Unity3D t>1 2.1 匯入.fbx並將匯入物件加入物理性質與程式 物理性質與參數設定 加入script(Unity中的程式碼) 2.2 網球場地設定 球場材質貼上 光線設定 加入script Ball.fbx , Racket.fbx, Player.fbx, etc. 球場與周圍環境 網球、球拍等….. 2.3 玩家與遊戲間互動 玩家回擊 動作判定 位置轉換 發球 給予球初速 動作判斷 規則、碰撞與分數判定 AI回擊 位置移動 揮拍時間判定 t=0 : 球的速度 : 球的位置 Display

  23. 3.3 Animated Object Component Creation Using 3Ds Max and Save to Unity3D(2/8) • Create Tennis racket plane circle cylinder Figure: 球拍製作方法

  24. 3.3 Animated Object Component Creation Using 3Ds Max and Save to Unity3D(3/8) • Material • To make objects more real.

  25. 3.3 Animated Object Component Creation Using 3Ds Max and Save to Unity3D(4/8) • The Process of Creating a Tennis Ball 1 2 ↑拉出一個立方體 ↑將其圓弧化 3 4 ↑選定凹槽之分段線 ↑凸顯所選之分段線

  26. 3.3 Animated Object Component Creation Using 3Ds Max and Save to Unity3D(5/8) 5 6 ↑球型化 ↑調整凹槽深度 7 8 ↑貼上材質 ↑網球形狀完成 26

  27. 3.3 Animated Object Component Creation Using 3Ds Max and Save to Unity3D(6/8) • Final Result

  28. 3.3 Animated Object Component Creation Using 3Ds Max and Save to Unity3D(7/8) • Use some object to compose a tennis net. • In Unity3D,using a invisible plane to allocate physical character. box cylinder Figure: Tennis net

  29. 3.3 Animated Object Component Creation Using 3Ds Max and Save to Unity3D(8/8) • Export .FBX file in 3DsMAX 將此物件輸出成.FBX檔案

  30. 4. Right Hand Point and Skeleton Tracking Using OpenNI(1/2) 校正後的 RGB Image Depth Map 0.2 Human Body Calibration for Skeleton Creation Using OpenNI Use and to Calibration 0.0 獲得深度圖與彩色圖 透過OpenNI操控Kinect 1.0 Right Hand Point and Skeleton Tracking Using OpenNI 偵測與追蹤torso(玩家正中心)和right hand關節點 輸出, RGB Image Depth Map t>1 t=1 Update , to Unity in any time. 2.0 Tennis Game Interaction between Human Motion and Animated Object Components 0.3 Animated Object Component Creation Using 3Ds MAX and Save to Unity3D t>1 2.1 匯入.fbx並將匯入物件加入物理性質與程式 物理性質與參數設定 加入script(Unity中的程式碼) 2.2 網球場地設定 球場材質貼上 光線設定 加入script Ball.fbx , Racket.fbx, Player.fbx, etc. 球場與周圍環境 網球、球拍等….. 2.3 玩家與遊戲間互動 玩家回擊 動作判定 位置轉換 發球 給予球初速 動作判斷 規則、碰撞與分數判定 AI回擊 位置移動 揮拍時間判定 t=0 : 球的速度 : 球的位置 Display

  31. 4. Right Hand Point and Skeleton Tracking Using OpenNI(2/2) • Track right hand pointby OpenNI: • Handpoint_control() • After calibration this class will detect right hand point. • Then, track right hand point and output to Unity. • This class will output all the time. • OpenNISkeleton(intskeletonnum) • 輸入skeleton的號碼,此class可回傳指定骨架座標 • After calibration, this class will detect skeleton point. • Then, track skeleton point and output to Unity. • This class will output all the time.

  32. 5. Tennis Game Interaction between Human Motion and Animated Object Components 校正後的 RGB Image Depth Map 0.2 Human Body Calibration for Skeleton Creation Using OpenNI Use and to Calibration 0.1 Depth Map and Color Image Creation Using OpenNI to Process Kinect 1.0 Right Hand Point and Skeleton Tracking Using OpenNI 偵測與追蹤torso(玩家正中心)和right hand關節點 輸出, RGB Image Depth Map t>1 t=1 Update , to Unity in any time. 2.0 Tennis Game Interaction between Human Motion and Animated Object Components 0.3 Animated Object Component Creation Using 3Ds MAX and Save to Unity3D t>1 2.1 匯入.fbx並將匯入物件加入物理性質與程式 物理性質與參數設定 加入script(Unity中的程式碼) 2.2 網球場地設定 球場材質貼上 光線設定 加入script Ball.fbx , Racket.fbx, Player.fbx, etc. 球場與周圍環境 網球、球拍等….. 2.3 玩家與遊戲間互動 玩家回擊 動作判定 位置轉換 發球 給予球初速 動作判斷 規則、碰撞與分數判定 AI回擊 位置移動 揮拍時間判定 t=0 : 球的速度 : 球的位置 Display

  33. 5.1 匯入.fbx並將匯入物件加入物理性質與程式 (1/3) • Import .FBX file in Unity3D Figure: We import “ball.FBX” into our game system

  34. 5.1 匯入.fbx並將匯入物件加入物理性質與程 式 (2/3) • 物理特性附加(以鋼體附加為例) 點選欲加入特性物件 選擇Component->Rigidbody 即可發現特性視窗多了 Rigidbody屬性

  35. 5.1 匯入.fbx並將匯入物件加入物理性質與程式(3/3) • Script附加方式 • Script為Unity中的程式碼,可獨立運作並互相影響,導入物件中。 左圖為遊戲物件,我們希望把右邊的Ball_Behavior的script附加於ball上,直接拖曳到物件上 由於球被附加上了Ball_Behavior的script,故其屬性多了一項Ball_Behavior

  36. 5.2 網球場地設定 (1/4) • Scene Setting • Terrain(我們需要細部修改場地與其附加程式,故此物件不由3Ds MAX畫出而是在Unity內完成) • Light • Camera

  37. 5.2 網球場地設定 (2/4) • Terrain-Tennis Court • Resolution • Width, Length and Height • Transform • Position • Location • scale 1. Create Terrain 2. Set Resolution 5. Set Transform • 3. Paint Terrain Texture 4. Add Net 6. Set Property 7. Set Material

  38. 5.2 網球場地設定 (3/4) • Light • Directional Light (figure a) • Point Light (figure b) • Spot Light (figure c) 1. Add GameObject 2. Set Transform 3. Set Property a. Directional Light c. Spot Light b. Point Light

  39. 5.2 網球場地設定 (4/4) • Camera • Projection • Perspective (figure a) • Orthographic (figure b) 1. Add Camera 2. Set Transform 3. Set Property a. Perspective b. Orthographic 選擇攝影機並修改projection選項

  40. 5.3 玩家與遊戲間互動 (1/6) 3. Play and Display by Unity 3.3 電腦玩家接球使用人工智慧 3.5 分數判定 3.1 發球(假設為玩家擊球) , 分數顯示 15->30->40 Deuce情況判定 獲勝條件判定 Predict falling location 拋球 改變球的速度為(0,2,0),使其往上 C set to 0 計算時間並揮拍,拍子與球碰撞 Change velocity of Ball Give S if C==1 Match motion 根據兩frame的做 相減,得到三維向量 ,根據查表得M 3.2 規則與碰撞判定 3.4 Player 接球 碰撞判定 球與人、場地、球網的碰撞決定 , 的變化 Hit zone detect If ( (<&& <) &&M!=0 ) Give , If T==1 規則判定 失誤 Ace, Return Ace, Out…. 球對球網 球對球拍 Match motion 揮拍 根據M來選擇動作並改變,拍子與球碰撞 , , 揮拍 根據M來選擇動作並改變,拍子與球碰撞 Give , If T==0 Change velocity of Ball Change velocity of Ball Display

  41. 5.3 玩家與遊戲間互動 -參數對照表 (2/6) : Location of player’s right hand point相對於Kinect. : Location of player’s torsopoint相對於Kinect. : Location of player’s location in Unity3D. : Location of ball in Unity3D. : Velocity of ball in Unity3D. : Collision times of ball with court. : 兩張frame內,右手的距離(三維向量) M : Which command match our motion. 0 is none. : 揮拍前與球的距離,尚未實作固令 : Player’s score : CPU’s score S : 誰得分(1為玩家 2為電腦) C: 是否計算 T: 最後一次誰擊球(1為玩家 0為電腦)

  42. 5.3 玩家與遊戲間互動 (3/6) 3. Play and Display by Unity 3.3 電腦玩家接球使用人工智慧 3.5 分數判定 3.1 發球(假設為玩家擊球) , 分數顯示 15->30->40 Deuce情況判定 獲勝條件判定 Predict falling location 拋球 改變球的速度為(0,2,0),使其往上 C set to 0 計算時間並揮拍,拍子與球碰撞 Change velocity of Ball Give S if C==1 Match motion 根據兩frame的做 相減,得到三維向量 ,根據查表得M 3.2 規則與碰撞判定 3.4 Player 接球 碰撞判定 球與人、場地、球網的碰撞決定 , 的變化 檢測玩家是否在球附近 If ( (<&& <) &&M!=0 ) Give , If T==1 規則判定 失分 Ace, Return Ace, Out…. 球對球網 球對球拍 Match motion 揮拍 根據M來選擇動作並改變,拍子與球碰撞 , , 揮拍 根據M來選擇動作並改變,拍子與球碰撞 Give , If T==0 Change velocity of Ball Change velocity of Ball Display

  43. 5.3 玩家與遊戲間互動 (4/6) 3. Play and Display by Unity 3.3 電腦玩家接球使用人工智慧 3.5 分數判定 3.1 發球(假設為玩家擊球) , 分數顯示 15->30->40 Deuce情況判定 獲勝條件判定 Predict falling location 拋球 改變球的速度為(0,2,0),使其往上 C set to 0 計算時間並揮拍,拍子與球碰撞 Change velocity of Ball Give S if C==1 Match motion 根據兩frame的做 相減,得到三維向量 ,根據查表得M 3.2 規則與碰撞判定 3.4 Player 接球 碰撞判定 球與人、場地、球網的碰撞決定 , 的變化 檢測玩家是否在球附近 If ( (<&& <) &&M!=0 ) Give , If T==1 規則判定 失分 Ace, Return Ace, Out…. 球對球網 球對球拍 Match motion 揮拍 根據M來選擇動作並改變,拍子與球碰撞 , , 揮拍 根據M來選擇動作並改變,拍子與球碰撞 Give , If T==0 Change velocity of Ball Change velocity of Ball Display 3.2與3.3之間數值傳遞不斷進行,因為球的狀態 需要再3.2中不斷更新

  44. 5.3 玩家與遊戲間互動 (5/6) 3. Play and Display by Unity 3.3 電腦玩家接球使用人工智慧 3.5 分數判定 3.1 發球(假設為玩家擊球) , 分數顯示 15->30->40 Deuce情況判定 獲勝條件判定 Predict falling location 拋球 改變球的速度為(0,2,0),使其往上 C set to 0 計算時間並揮拍,拍子與球碰撞 Change velocity of Ball Give S if C==1 Match motion 根據兩frame的做 相減,得到三維向量 ,根據查表得M 3.2 規則與碰撞判定 3.4 Player 接球 碰撞判定 球與人、場地、球網的碰撞決定 , 的變化 檢測玩家是否在球附近 If ( (<&& <) &&M!=0 ) Give , If T==1 規則判定 失分 Ace, Return Ace, Out…. 球對球網 球對球拍 Match motion 揮拍 根據M來選擇動作並改變,拍子與球碰撞 , , 揮拍 根據M來選擇動作並改變,拍子與球碰撞 Give , If T==0 Change velocity of Ball Change velocity of Ball Display 3.2與3.4之間數值傳遞不斷進行,因為球的狀態需要再3.2中不斷更新,以左方突來說玩家不在球附近,儘管有揮拍動作但還是無法回擊球,因此碰撞判定得知球碰地兩下而沒人接,規則判定為失分,接球失敗,進入分數判定。

  45. 5.3 玩家與遊戲間互動 (6/6) 3. Play and Display by Unity 3.3 電腦玩家接球使用人工智慧 3.5 分數判定 3.1 發球(假設為玩家擊球) , 分數顯示 15->30->40 Deuce情況判定 獲勝條件判定 Predict falling location 拋球 改變球的速度為(0,2,0),使其往上 C set to 0 Change velocity of Ball Give S if C==1 Match motion 根據兩frame的做 相減,得到三維向量 ,根據查表得M 3.2 規則與碰撞判定 3.4 Player 接球 碰撞 球與人、場地、球網、拍子的碰撞決定 , 的變化 檢測玩家是否在球附近 If ( (<&& <) &&M!=0 ) Give , If T==1 規則 失分 Ace, Return Ace, Out…. 球對球網 球對球拍 Match motion 揮拍 根據M來選擇動作並改變 , , 揮拍 根據M來選擇動作並改變 Give , If T==0 Change -- velocity of Ball Change -- velocity of Ball Display

  46. 5.3.1 發球 (1/2) • 向上拋球 • We use rigidbody. Rigidbody類別控制script所附加物體的基本特性,包含速度、力、加速度和位置。 • Throw up the ball, so rigidbody.velocity.y=2. • rigidbody在此為球體本身,底下的資料結構velocity為其速度,y則為y軸上的速度,在Unity中可隨時改變物體的速度,而球已被加上鋼體,固往上丟後會受重力影響到最高點後下墜。

  47. 5.3.1 發球 (2/2) • 擊球 • 抓取兩frame的,假設第一張為,第二張為,,將查表得M。 • 根據M做出不同揮拍動作並改變。

  48. 5.3.2 規則與碰撞判定 (1/5) • 碰撞判定 • OnTriggerEnter() • 在script中使用,可用來偵測是否發生碰撞 • 使用此法可偵測球與指定物件碰撞 Ball Tennis Court In court’s script: OnTriggerEnter(){ 尋找物件“Ball”底下的ballmove script; 修改ballmove script的++; }

  49. 5.3.2 規則與碰撞判定 (2/5) • 碰撞判定 • OnTriggerEnter() • 在script中使用,可用來偵測是否發生碰撞 • 使用此法可偵測球與指定物件碰撞 Collision Happen!!! ++ Ball Tennis Court In court script: OnTriggerEnter(){ 尋找物件“Ball”; 修改Ball的script並使++; }

  50. 5.3.2規則與碰撞判定(3/5) • 碰撞判定 • 球與拍子的碰撞 • Lichen: 兩者皆為鋼體,可由系統決定碰撞後球飛出的方向或將球的速度與方向寫成幾個固定的數值。 • =0 (打擊後落地次數應重算) • T從0與1間交換 (T儲存最後一次打擊的人物編號) • 球與場地的碰撞 • 發生碰撞則++,++,當實作規則判定(出界或得分)

More Related