Cliff   03-07-2014, 08:50 PM
#10
Quote:ควรแก้ไขยังไงครับ ไปไม่เป็นแฮะ Forever Alone

จากที่อ่าน code เดาว่า น่าจะเป็น code ควบคุม state ตัวละคร
ซึ่งมี 3 สถานะคือ
1. ยืนนิ่งๆ (Idle)
2. เดิน (Walk)
3. วิ่ง (Sprint)

ดังนั้น
มันขาด State ที่เปลี่ยน PlayerState = 1 ครับ
ดังนั้นต้อง เพิ่มเข้าไป ดังนี้
Code:
function PlayerStateController()
{
     if (Input.GetAxis("Vertical")!=0 || Input.GetAxis("Horizontal") !=0)
     {
          if (Input.GetButton("Sprint"))
          {
               PlayerState = 2;
          }
          else if( เงื่อนไขการ walk )
          {
               PlayerState = 1;
          }
     }
     else
     {
          PlayerState = 0;
     }
}

ส่วนเงื่อนไขการเดิน ผมขอเดาว่า น่าจะเป็นกดปุ่ม AWSD หรือเปล่า
ถ้าเป็นแบบนี้ ให้ใส่
Code:
Input.GetKeyDown(Keycode.A) || Input.GetKeyDown(Keycode.W) Input.GetKeyDown(Keycode.S) || Input.GetKeyDown(Keycode.D)
เข้าไปในวงเล็บครับ
This post was last modified: 03-07-2014, 08:57 PM by Cliff.
  
Users browsing this thread: 1 Guest(s)
Powered By MyBB, © 2002-2024 MyBB Group.
Made with by Curves UI.