private void HandleWSAD() { //处理WSAD输入(改变角色的方向) float moveHorizontal = Input.GetAxis("Horizontal"); float moveVertical = Input.GetAxis("Vertical"); if (moveHorizontal > 0.0f) { if (moveVertical > 0.0f) { objectBehaviour.Move(ObjectBehaviour.MoveDirection.FrontRight); } else { objectBehaviour.Move(ObjectBehaviour.MoveDirection.Right); } } else if (moveHorizontal < 0.0f) { if (moveVertical > 0.0f) { objectBehaviour.Move(ObjectBehaviour.MoveDirection.FrontLeft); } else { objectBehaviour.Move(ObjectBehaviour.MoveDirection.Left); } } else if (moveVertical > 0.0f) { if (playerBehaviour.flyState == PlayerBehaviour.FlyState.Flying) { Vector3 towards = objectBehaviour.GetForwardDirection(); playerBehaviour.MoveInSky(towards); } else if (playerBehaviour.enterSky && playerBehaviour.flyState == PlayerBehaviour.FlyState.WaitForFly) { playerBehaviour.MoveInSeaSurface(); } else { objectBehaviour.Move(ObjectBehaviour.MoveDirection.Front); } } else { objectBehaviour.Move(ObjectBehaviour.MoveDirection.Stay); } }
protected void Wander() { resetCountForWander -= Time.deltaTime; if (resetCountForWander <= 0.0f) { float p = Random.Range(0.0f, 1.0f); if (p < 0.8f) { turnHorizontal = Random.Range(-0.3f, 0.3f); turnVertical = Random.Range(-0.1f, 0.1f); resetCountForWander = Random.Range(2.0f, 5.0f); } else { Vector3 dir = GetRandomDirection(); objectBehaviour.SetForwardDirecion(dir); turnHorizontal = 0.0f; turnVertical = 0.0f; resetCountForWander = 0.1f; } } objectBehaviour.Turn(turnHorizontal, turnVertical); objectBehaviour.Move(ObjectBehaviour.MoveDirection.Front, speed); }
void TestMove() { //处理WSAD输入(改变角色的方向) float moveHorizontal = Input.GetAxis("Horizontal"); float moveVertical = Input.GetAxis("Vertical"); if (moveHorizontal > 0.0f) { if (moveVertical > 0.0f) { testMod.Move(ObjectBehaviour.MoveDirection.FrontRight); } else { testMod.Move(ObjectBehaviour.MoveDirection.Right); } } else if (moveHorizontal < 0.0f) { if (moveVertical > 0.0f) { testMod.Move(ObjectBehaviour.MoveDirection.FrontLeft); } else { testMod.Move(ObjectBehaviour.MoveDirection.Left); } } else if (moveVertical > 0.0f) { testMod.Move(ObjectBehaviour.MoveDirection.Front); } else { testMod.Move(ObjectBehaviour.MoveDirection.Stay); } }