浏览代码

Improvement: PlayerMovement Logic. Fix: Removed duplicate Rebind UI Updates. Binding Override Reset when switching Control Schemes

/V2
andytouch 4 年前
当前提交
da1db21c
共有 7 个文件被更改,包括 32 次插入35 次删除
  1. 8
      InputSystem_Warriors_Project/Assets/PhysicsMaterials/PhysicsMaterial_Warrior.physicMaterial
  2. 6
      InputSystem_Warriors_Project/Assets/Prefabs/Warrior/Player_Warrior.prefab
  3. 10
      InputSystem_Warriors_Project/Assets/Scenes/Scene_Example_Warriors.unity
  4. 23
      InputSystem_Warriors_Project/Assets/Scripts/Behaviours/Player/PlayerController.cs
  5. 9
      InputSystem_Warriors_Project/Assets/Scripts/Behaviours/Player/PlayerMovementBehaviour.cs
  6. 8
      InputSystem_Warriors_Project/Assets/Scripts/Behaviours/UI/UIPanelRebindBehaviour.cs
  7. 3
      InputSystem_Warriors_Project/Assets/Scripts/Behaviours/UI/UIRebindActionBehaviour.cs

8
InputSystem_Warriors_Project/Assets/PhysicsMaterials/PhysicsMaterial_Warrior.physicMaterial


m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: PhysicsMaterial_Warrior
dynamicFriction: 0
staticFriction: 0
dynamicFriction: 1
staticFriction: 1
frictionCombine: 0
bounceCombine: 0
frictionCombine: 2
bounceCombine: 2

6
InputSystem_Warriors_Project/Assets/Prefabs/Warrior/Player_Warrior.prefab


playerAnimationBehaviour: {fileID: 7582353321118191811}
playerVisualsBehaviour: {fileID: 16277596}
playerInput: {fileID: 1743518200311987064}
movementSmoothingSpeed: 2
movementSmoothingSpeed: 5
--- !u!114 &1743518200311987064
MonoBehaviour:
m_ObjectHideFlags: 0

m_GameObject: {fileID: 1743518200311987069}
serializedVersion: 2
m_Mass: 1
m_Drag: 2
m_Drag: 3
m_AngularDrag: 0.05
m_UseGravity: 1
m_IsKinematic: 0

m_Name:
m_EditorClassIdentifier:
playerRigidbody: {fileID: 1743518200311987066}
movementSpeed: 6
movementSpeed: 5
rotationSpeed: 0.5
--- !u!1 &1743518200780429236
GameObject:

10
InputSystem_Warriors_Project/Assets/Scenes/Scene_Example_Warriors.unity


m_Name:
m_EditorClassIdentifier:
m_BindingMode: 5
m_FollowOffset: {x: 0, y: 6.779932, z: -2.050096}
m_FollowOffset: {x: 0, y: 2.188531, z: -5.740778}
m_XDamping: 1
m_YDamping: 1
m_ZDamping: 1

m_Name:
m_EditorClassIdentifier:
m_BindingMode: 5
m_FollowOffset: {x: 0, y: 6.779932, z: -2.050096}
m_FollowOffset: {x: 0, y: 2.188531, z: -5.740778}
m_XDamping: 1
m_YDamping: 1
m_ZDamping: 1

m_Name:
m_EditorClassIdentifier:
m_BindingMode: 5
m_FollowOffset: {x: 0, y: 6.779932, z: -2.050096}
m_FollowOffset: {x: 0, y: 2.188531, z: -5.740778}
m_XDamping: 1
m_YDamping: 1
m_ZDamping: 1

m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1833978498}
m_LocalRotation: {x: 0.18110336, y: -0.002146129, z: 0.00039520723, w: 0.9834617}
m_LocalPosition: {x: 0.016107835, y: -4.5914693, z: -3.690742}
m_LocalRotation: {x: 0.14559379, y: -0.0021589955, z: 0.00031772253, w: 0.98934203}
m_LocalPosition: {x: 0.015907818, y: -5.066736, z: -3.6449027}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 193751149}

23
InputSystem_Warriors_Project/Assets/Scripts/Behaviours/Player/PlayerController.cs


private string actionMapGameplay = "Player Controls";
private string actionMapMenu = "Menu Controls";
//Current Control Scheme
private string currentControlScheme;
currentControlScheme = playerInput.currentControlScheme;
playerMovementBehaviour.SetupBehaviour();
playerAnimationBehaviour.SetupBehaviour();
playerVisualsBehaviour.SetupBehaviour(playerID, playerInput);

//(IE: Keyboard -> Xbox Controller)
public void OnControlsChanged()
{
playerVisualsBehaviour.UpdatePlayerVisuals();
if(playerInput.currentControlScheme != currentControlScheme)
{
currentControlScheme = playerInput.currentControlScheme;
playerVisualsBehaviour.UpdatePlayerVisuals();
RemoveAllBindingOverrides();
}
}
//This is automatically called from PlayerInput, when the input device has been disconnected and can not be identified

yield return new WaitForSeconds(0.1f);
playerVisualsBehaviour.UpdatePlayerVisuals();
}

playerInput.ActivateInput();
break;
}
}
void RemoveAllBindingOverrides()
{
InputActionRebindingExtensions.RemoveAllBindingOverrides(playerInput.currentActionMap);
}

9
InputSystem_Warriors_Project/Assets/Scripts/Behaviours/Player/PlayerMovementBehaviour.cs


void TurnThePlayer()
{
//transform.rotation = Quaternion.Slerp (transform.rotation, Quaternion.LookRotation (CameraDirection(-movementDirection)), rotationSpeed);
/*
if (movementDirection.sqrMagnitude > 0.01f) {
Quaternion targetRotation = Quaternion.LookRotation( CameraDirection(-movementDirection) );
playerRigidbody.MoveRotation(targetRotation);
}
*/
}

8
InputSystem_Warriors_Project/Assets/Scripts/Behaviours/UI/UIPanelRebindBehaviour.cs


uiRebindActionBehaviours[i].UpdateBehaviour();
}
}
public void ResetAllBindings()
{
for(int i = 0; i < uiRebindActionBehaviours.Length; i++)
{
uiRebindActionBehaviours[i].ResetBinding();
}
}
}

3
InputSystem_Warriors_Project/Assets/Scripts/Behaviours/UI/UIRebindActionBehaviour.cs


.WithControlsExcluding("<Mouse>/delta")
.WithControlsExcluding("<Gamepad>/Start")
.WithControlsExcluding("<Keyboard>/p")
.WithControlsExcluding("<Keyboard>/escape")
.OnMatchWaitForAnother(0.1f)
.OnComplete(operation => RebindCompleted());

void UpdateActionDisplayUI()
{
actionNameDisplayText.SetText(actionName);
UpdateBindingDisplayUI();
}
void UpdateBindingDisplayUI()

正在加载...
取消
保存