Roman 7bbfa625a0 任务:搭建基本玩法
1.让马可以跳跃
(1.测试,如果我给马的刚体一个(1,1)的力代表跳跃,是否可行?
Good Job!通过测试,可以通过给力的方式使马整体起飞,而且控制点和马蹄都会随之起飞,是理想的状态。
(2.让马并拢每一组腿,当按住某键,使该组腿并拢,也就是消除输入偏差。当松开键,重新设置输入偏差,使双腿分开。
DONE
(3.从输入中获取信息,当两腿均并拢,进入跳跃模式,否则离开跳跃模式,在跳跃模式下,如何通过输入计算出应该给出多大、哪个方向的的跳跃力是核心和难点
(4.马脚和马脚的控制点很难控制,数据也经常抖动,我不想通过这两个变量来计算跳跃的力。我打算直接通过输入值判断
(5.尝试:首先,若处于跳跃模式,每帧记录上一帧输入,并计算一个瞬时速度,当瞬时速度的y大于0,也就代表此时腿在上升,在预备,不考虑。若瞬时速度的y小于0,说明腿开始下降,可能会跳起。此时判断此瞬时速度的模长是否大于某个阈值,若是,进入戒备状态,此后的若干帧后,有任何一帧再低于阈值,说明输入结束,输出最后的速度,并给予马刚体。若此时瞬时速度的模长小于阈值
,说明太慢,不记录。在这个戒备状态中的每一帧,需要记录瞬时速度,并累计影响,最终经过乘以调整值、取反(因为是相对作用)操作,得到需要赋予马的力,然后把力赋给马刚体,完成一次跳跃
(6.Good!初步尝试有效。在马着地后,重置跳跃状态,即可完成循环,开始下一次跳跃。

至此,马基本可以跳跃,但是手感极差,并且键鼠几乎没有操作空间,需要后续进一步优化……
2022-07-26 00:00:56 +08:00

489 lines
20 KiB
C#

//------------------------------------------------------------------------------
// <auto-generated>
// This code was auto-generated by com.unity.inputsystem:InputActionCodeGenerator
// version 1.3.0
// from Assets/勍/输入映射/PlayerC.inputactions
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Utilities;
public partial class @PlayerC : IInputActionCollection2, IDisposable
{
public InputActionAsset asset { get; }
public @PlayerC()
{
asset = InputActionAsset.FromJson(@"{
""name"": ""PlayerC"",
""maps"": [
{
""name"": ""GamePlay"",
""id"": ""d066c560-5817-4703-aecc-a975f13f7093"",
""actions"": [
{
""name"": ""MoveBackFoot"",
""type"": ""Value"",
""id"": ""1e173331-d5ad-4f9b-a307-56bf2eda0151"",
""expectedControlType"": ""Vector2"",
""processors"": """",
""interactions"": """",
""initialStateCheck"": true
},
{
""name"": ""MoveFrontFoot"",
""type"": ""Value"",
""id"": ""d198c764-78f7-416a-a6b6-611e7f6fe52e"",
""expectedControlType"": ""Vector2"",
""processors"": """",
""interactions"": """",
""initialStateCheck"": true
},
{
""name"": ""MergeBackFoot"",
""type"": ""Button"",
""id"": ""8288e092-59fe-4ec2-8cf0-6405751e4d50"",
""expectedControlType"": ""Button"",
""processors"": """",
""interactions"": """",
""initialStateCheck"": false
},
{
""name"": ""MergeFrontFoot"",
""type"": ""Button"",
""id"": ""dff57601-4077-445d-880b-15d1f6794338"",
""expectedControlType"": ""Button"",
""processors"": """",
""interactions"": """",
""initialStateCheck"": false
}
],
""bindings"": [
{
""name"": ""Keyboard"",
""id"": ""2f29b289-9196-49f9-879f-6e48c0fd135e"",
""path"": ""2DVector"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""MoveBackFoot"",
""isComposite"": true,
""isPartOfComposite"": false
},
{
""name"": ""up"",
""id"": ""070f9c54-d3c3-4f9a-909b-c86b36554086"",
""path"": ""<Keyboard>/w"",
""interactions"": """",
""processors"": """",
""groups"": ""GamePlay"",
""action"": ""MoveBackFoot"",
""isComposite"": false,
""isPartOfComposite"": true
},
{
""name"": ""down"",
""id"": ""044805b5-ecef-4476-9a64-00f88f141f3f"",
""path"": ""<Keyboard>/s"",
""interactions"": """",
""processors"": """",
""groups"": ""GamePlay"",
""action"": ""MoveBackFoot"",
""isComposite"": false,
""isPartOfComposite"": true
},
{
""name"": ""left"",
""id"": ""2a896e80-041c-4c01-968a-793d2a741a6c"",
""path"": ""<Keyboard>/a"",
""interactions"": """",
""processors"": """",
""groups"": ""GamePlay"",
""action"": ""MoveBackFoot"",
""isComposite"": false,
""isPartOfComposite"": true
},
{
""name"": ""right"",
""id"": ""177e26dd-3a72-47e3-951a-3f9b3a942d40"",
""path"": ""<Keyboard>/d"",
""interactions"": """",
""processors"": """",
""groups"": ""GamePlay"",
""action"": ""MoveBackFoot"",
""isComposite"": false,
""isPartOfComposite"": true
},
{
""name"": ""GamePad"",
""id"": ""8e7cc629-4a8a-46f1-914b-46d7fd8da422"",
""path"": ""2DVector(mode=2)"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""MoveBackFoot"",
""isComposite"": true,
""isPartOfComposite"": false
},
{
""name"": ""up"",
""id"": ""aee182e3-5f55-494e-9293-cd5810f4a2dd"",
""path"": ""<Gamepad>/leftStick/up"",
""interactions"": """",
""processors"": """",
""groups"": ""GamePlay"",
""action"": ""MoveBackFoot"",
""isComposite"": false,
""isPartOfComposite"": true
},
{
""name"": ""down"",
""id"": ""6d7d49a7-f87d-45cb-81bb-a8139654b64b"",
""path"": ""<Gamepad>/leftStick/down"",
""interactions"": """",
""processors"": """",
""groups"": ""GamePlay"",
""action"": ""MoveBackFoot"",
""isComposite"": false,
""isPartOfComposite"": true
},
{
""name"": ""left"",
""id"": ""dbbc6bdf-e7d3-4a8b-8156-44b49947fb21"",
""path"": ""<Gamepad>/leftStick/left"",
""interactions"": """",
""processors"": """",
""groups"": ""GamePlay"",
""action"": ""MoveBackFoot"",
""isComposite"": false,
""isPartOfComposite"": true
},
{
""name"": ""right"",
""id"": ""bd9d31fa-3750-42db-a37a-fd6b24b35e29"",
""path"": ""<Gamepad>/leftStick/right"",
""interactions"": """",
""processors"": """",
""groups"": ""GamePlay"",
""action"": ""MoveBackFoot"",
""isComposite"": false,
""isPartOfComposite"": true
},
{
""name"": ""Keyboard"",
""id"": ""847b8737-4b1b-4699-aca1-9ac3de703a77"",
""path"": ""2DVector"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""MoveFrontFoot"",
""isComposite"": true,
""isPartOfComposite"": false
},
{
""name"": ""up"",
""id"": ""8b9631ca-0fa6-4272-ab7d-5bee70d9d367"",
""path"": ""<Keyboard>/upArrow"",
""interactions"": """",
""processors"": """",
""groups"": ""GamePlay"",
""action"": ""MoveFrontFoot"",
""isComposite"": false,
""isPartOfComposite"": true
},
{
""name"": ""down"",
""id"": ""bff77e64-88d3-41a3-9600-b07b5940fe0d"",
""path"": ""<Keyboard>/downArrow"",
""interactions"": """",
""processors"": """",
""groups"": ""GamePlay"",
""action"": ""MoveFrontFoot"",
""isComposite"": false,
""isPartOfComposite"": true
},
{
""name"": ""left"",
""id"": ""3d72b984-a8e0-432a-84fa-2501e1f0bf90"",
""path"": ""<Keyboard>/leftArrow"",
""interactions"": """",
""processors"": """",
""groups"": ""GamePlay"",
""action"": ""MoveFrontFoot"",
""isComposite"": false,
""isPartOfComposite"": true
},
{
""name"": ""right"",
""id"": ""94fd6f98-3a9d-4ca6-9934-f9ffb5ac487f"",
""path"": ""<Keyboard>/rightArrow"",
""interactions"": """",
""processors"": """",
""groups"": ""GamePlay"",
""action"": ""MoveFrontFoot"",
""isComposite"": false,
""isPartOfComposite"": true
},
{
""name"": ""GamePad"",
""id"": ""6e216e7e-d474-4342-af09-0f1936433ad9"",
""path"": ""2DVector(mode=2)"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""MoveFrontFoot"",
""isComposite"": true,
""isPartOfComposite"": false
},
{
""name"": ""up"",
""id"": ""51d7e337-7cdf-4c2e-9c93-7da2ace9f1e5"",
""path"": ""<Gamepad>/rightStick/up"",
""interactions"": """",
""processors"": """",
""groups"": ""GamePlay"",
""action"": ""MoveFrontFoot"",
""isComposite"": false,
""isPartOfComposite"": true
},
{
""name"": ""down"",
""id"": ""36eb00e0-f26f-4fd4-a154-364f09ec4244"",
""path"": ""<Gamepad>/rightStick/down"",
""interactions"": """",
""processors"": """",
""groups"": ""GamePlay"",
""action"": ""MoveFrontFoot"",
""isComposite"": false,
""isPartOfComposite"": true
},
{
""name"": ""left"",
""id"": ""4163f149-fe0e-43ce-ab08-95fbb2854cf6"",
""path"": ""<Gamepad>/rightStick/left"",
""interactions"": """",
""processors"": """",
""groups"": ""GamePlay"",
""action"": ""MoveFrontFoot"",
""isComposite"": false,
""isPartOfComposite"": true
},
{
""name"": ""right"",
""id"": ""2a85b7b4-027a-4d5b-abf6-977ed6338453"",
""path"": ""<Gamepad>/rightStick/right"",
""interactions"": """",
""processors"": """",
""groups"": ""GamePlay"",
""action"": ""MoveFrontFoot"",
""isComposite"": false,
""isPartOfComposite"": true
},
{
""name"": """",
""id"": ""6473b7f1-d103-4c52-83b5-111733afdc6d"",
""path"": ""<Gamepad>/leftShoulder"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""MergeBackFoot"",
""isComposite"": false,
""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""98454c00-038e-4008-91b0-21098bc7423c"",
""path"": ""<Keyboard>/shift"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""MergeBackFoot"",
""isComposite"": false,
""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""ec93b4c2-ff5d-4c0f-bcf7-ea1788cabb6f"",
""path"": ""<Gamepad>/rightShoulder"",
""interactions"": """",
""processors"": """",
""groups"": ""GamePlay"",
""action"": ""MergeFrontFoot"",
""isComposite"": false,
""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""615c7cea-f9d0-458c-a7e1-04a9ee39a068"",
""path"": ""<Keyboard>/space"",
""interactions"": """",
""processors"": """",
""groups"": ""GamePlay"",
""action"": ""MergeFrontFoot"",
""isComposite"": false,
""isPartOfComposite"": false
}
]
}
],
""controlSchemes"": [
{
""name"": ""GamePlay"",
""bindingGroup"": ""GamePlay"",
""devices"": [
{
""devicePath"": ""<Gamepad>"",
""isOptional"": true,
""isOR"": false
},
{
""devicePath"": ""<Keyboard>"",
""isOptional"": false,
""isOR"": false
}
]
}
]
}");
// GamePlay
m_GamePlay = asset.FindActionMap("GamePlay", throwIfNotFound: true);
m_GamePlay_MoveBackFoot = m_GamePlay.FindAction("MoveBackFoot", throwIfNotFound: true);
m_GamePlay_MoveFrontFoot = m_GamePlay.FindAction("MoveFrontFoot", throwIfNotFound: true);
m_GamePlay_MergeBackFoot = m_GamePlay.FindAction("MergeBackFoot", throwIfNotFound: true);
m_GamePlay_MergeFrontFoot = m_GamePlay.FindAction("MergeFrontFoot", throwIfNotFound: true);
}
public void Dispose()
{
UnityEngine.Object.Destroy(asset);
}
public InputBinding? bindingMask
{
get => asset.bindingMask;
set => asset.bindingMask = value;
}
public ReadOnlyArray<InputDevice>? devices
{
get => asset.devices;
set => asset.devices = value;
}
public ReadOnlyArray<InputControlScheme> controlSchemes => asset.controlSchemes;
public bool Contains(InputAction action)
{
return asset.Contains(action);
}
public IEnumerator<InputAction> GetEnumerator()
{
return asset.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
public void Enable()
{
asset.Enable();
}
public void Disable()
{
asset.Disable();
}
public IEnumerable<InputBinding> bindings => asset.bindings;
public InputAction FindAction(string actionNameOrId, bool throwIfNotFound = false)
{
return asset.FindAction(actionNameOrId, throwIfNotFound);
}
public int FindBinding(InputBinding bindingMask, out InputAction action)
{
return asset.FindBinding(bindingMask, out action);
}
// GamePlay
private readonly InputActionMap m_GamePlay;
private IGamePlayActions m_GamePlayActionsCallbackInterface;
private readonly InputAction m_GamePlay_MoveBackFoot;
private readonly InputAction m_GamePlay_MoveFrontFoot;
private readonly InputAction m_GamePlay_MergeBackFoot;
private readonly InputAction m_GamePlay_MergeFrontFoot;
public struct GamePlayActions
{
private @PlayerC m_Wrapper;
public GamePlayActions(@PlayerC wrapper) { m_Wrapper = wrapper; }
public InputAction @MoveBackFoot => m_Wrapper.m_GamePlay_MoveBackFoot;
public InputAction @MoveFrontFoot => m_Wrapper.m_GamePlay_MoveFrontFoot;
public InputAction @MergeBackFoot => m_Wrapper.m_GamePlay_MergeBackFoot;
public InputAction @MergeFrontFoot => m_Wrapper.m_GamePlay_MergeFrontFoot;
public InputActionMap Get() { return m_Wrapper.m_GamePlay; }
public void Enable() { Get().Enable(); }
public void Disable() { Get().Disable(); }
public bool enabled => Get().enabled;
public static implicit operator InputActionMap(GamePlayActions set) { return set.Get(); }
public void SetCallbacks(IGamePlayActions instance)
{
if (m_Wrapper.m_GamePlayActionsCallbackInterface != null)
{
@MoveBackFoot.started -= m_Wrapper.m_GamePlayActionsCallbackInterface.OnMoveBackFoot;
@MoveBackFoot.performed -= m_Wrapper.m_GamePlayActionsCallbackInterface.OnMoveBackFoot;
@MoveBackFoot.canceled -= m_Wrapper.m_GamePlayActionsCallbackInterface.OnMoveBackFoot;
@MoveFrontFoot.started -= m_Wrapper.m_GamePlayActionsCallbackInterface.OnMoveFrontFoot;
@MoveFrontFoot.performed -= m_Wrapper.m_GamePlayActionsCallbackInterface.OnMoveFrontFoot;
@MoveFrontFoot.canceled -= m_Wrapper.m_GamePlayActionsCallbackInterface.OnMoveFrontFoot;
@MergeBackFoot.started -= m_Wrapper.m_GamePlayActionsCallbackInterface.OnMergeBackFoot;
@MergeBackFoot.performed -= m_Wrapper.m_GamePlayActionsCallbackInterface.OnMergeBackFoot;
@MergeBackFoot.canceled -= m_Wrapper.m_GamePlayActionsCallbackInterface.OnMergeBackFoot;
@MergeFrontFoot.started -= m_Wrapper.m_GamePlayActionsCallbackInterface.OnMergeFrontFoot;
@MergeFrontFoot.performed -= m_Wrapper.m_GamePlayActionsCallbackInterface.OnMergeFrontFoot;
@MergeFrontFoot.canceled -= m_Wrapper.m_GamePlayActionsCallbackInterface.OnMergeFrontFoot;
}
m_Wrapper.m_GamePlayActionsCallbackInterface = instance;
if (instance != null)
{
@MoveBackFoot.started += instance.OnMoveBackFoot;
@MoveBackFoot.performed += instance.OnMoveBackFoot;
@MoveBackFoot.canceled += instance.OnMoveBackFoot;
@MoveFrontFoot.started += instance.OnMoveFrontFoot;
@MoveFrontFoot.performed += instance.OnMoveFrontFoot;
@MoveFrontFoot.canceled += instance.OnMoveFrontFoot;
@MergeBackFoot.started += instance.OnMergeBackFoot;
@MergeBackFoot.performed += instance.OnMergeBackFoot;
@MergeBackFoot.canceled += instance.OnMergeBackFoot;
@MergeFrontFoot.started += instance.OnMergeFrontFoot;
@MergeFrontFoot.performed += instance.OnMergeFrontFoot;
@MergeFrontFoot.canceled += instance.OnMergeFrontFoot;
}
}
}
public GamePlayActions @GamePlay => new GamePlayActions(this);
private int m_GamePlaySchemeIndex = -1;
public InputControlScheme GamePlayScheme
{
get
{
if (m_GamePlaySchemeIndex == -1) m_GamePlaySchemeIndex = asset.FindControlSchemeIndex("GamePlay");
return asset.controlSchemes[m_GamePlaySchemeIndex];
}
}
public interface IGamePlayActions
{
void OnMoveBackFoot(InputAction.CallbackContext context);
void OnMoveFrontFoot(InputAction.CallbackContext context);
void OnMergeBackFoot(InputAction.CallbackContext context);
void OnMergeFrontFoot(InputAction.CallbackContext context);
}
}