This commit is contained in:
yzx 2024-01-11 17:38:24 +08:00
parent 6b6ecf593e
commit 0ca8d49c68
3 changed files with 57 additions and 19 deletions

View File

@ -52,6 +52,12 @@ namespace EVP
// 将输入值从 0-100 范围映射到 0-1 范围
xxxx = Mathf.Clamp(value, 0, 100) / 100.0f;
}
public float steerInput;
public float forwardInput;
public float reverseInput;
// public float xxxxxx;
void FixedUpdate()
{
@ -59,11 +65,11 @@ namespace EVP
// Read the user input
float steerInput = Mathf.Clamp(Input.GetAxis(steerAxis), -1.0f, 1.0f);
steerInput = Mathf.Clamp(Input.GetAxis(steerAxis), -1.0f, 1.0f);
float handbrakeInput = Mathf.Clamp01(Input.GetAxis(handbrakeAxis));
float forwardInput = 0.0f;
float reverseInput = 0.0f;
forwardInput = 0.0f;
reverseInput = 0.0f;
// Debug.Log("前轮控制左右的参数----->" + steerInput);
if (throttleAndBrakeInput == ThrottleAndBrakeInput.SeparateAxes)
@ -79,9 +85,9 @@ namespace EVP
// forwardInput = Mathf.Clamp01(xxxx);
// Debug.Log(Mathf.Clamp01(xxxx));
// forwardInput = xxxxxx;
// Debug.Log("前轮控制左右的参数----->" + steerInput);
// Debug.Log("往前的参数----->" + forwardInput);
// Debug.Log("往后的参数----->" + reverseInput);
Debug.Log("前轮控制左右的参数----->" + steerInput);
Debug.Log("往前的参数----->" + forwardInput);
Debug.Log("往后的参数----->" + reverseInput);
// Translate forward/reverse to vehicle input
float throttleInput = 0.0f;

View File

@ -397307,6 +397307,18 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: b4decbca4aaf413abd074ba71736660a, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &1276762325 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 11461196, guid: 4292160a5e1fde347934ac660b2c5d30,
type: 3}
m_PrefabInstance: {fileID: 2037673174}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1276762317}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ca79ba03ebacd504783b096c3667cfbd, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &1276762328
MonoBehaviour:
m_ObjectHideFlags: 0
@ -397342,6 +397354,8 @@ MonoBehaviour:
m_EditorClassIdentifier:
turnSignalController: {fileID: 1276762328}
vehicleController: {fileID: 2037673176}
vehicleStandardInput: {fileID: 1276762325}
accidentManager: {fileID: 1323185945}
cam1: {fileID: 1136185827}
cam2: {fileID: 1785647646}
menuUI: {fileID: 1648579876}

View File

@ -6,22 +6,22 @@ namespace Script.Manaegr
{
public class CarInputManager : MonoBehaviour
{
public TurnSignalController turnSignalController;
public VehicleController vehicleController;
public VehicleStandardInput vehicleStandardInput;
public AccidentManager accidentManager;
public GameObject cam1;
public GameObject cam2;
public GameObject menuUI;
public GameObject carInfoUI;
public AnimationController ygq;
private bool isYgq = false;
public void Init()
{
vehicleController.maxSpeedForward = 11;
@ -35,18 +35,18 @@ namespace Script.Manaegr
{
turnSignalController.SetSignal(1);
}
if (Input.GetKeyDown(KeyCode.K))
{
turnSignalController.SetSignal(3);
}
if (Input.GetKeyDown(KeyCode.L))
{
turnSignalController.SetSignal(2);
}
//切换车内视角
if (Input.GetKeyDown(KeyCode.U))
{
@ -61,6 +61,7 @@ namespace Script.Manaegr
cam2.SetActive(false);
}
}
//雨刮器
if (Input.GetKeyDown(KeyCode.I))
{
@ -75,7 +76,7 @@ namespace Script.Manaegr
ygq.StopAnimationLoop();
}
}
//菜单
if (Input.GetKeyDown(KeyCode.Escape))
{
@ -88,9 +89,26 @@ namespace Script.Manaegr
menuUI.SetActive(true);
}
}
if (vehicleStandardInput.forwardInput >= 1)
{
if (vehicleStandardInput.steerInput >= 1) //右
{
if (turnSignalController.turnSignalState != TurnSignalState.)
{
accidentManager.PlayAnimationSequence("MsgWinAnimOpen", "MsgWinAnimClose");
accidentManager.uis.transform.Find("UI/转向").gameObject.SetActive(true);
}
}
else if (vehicleStandardInput.steerInput <= -1) //左
{
if (turnSignalController.turnSignalState != TurnSignalState.)
{
accidentManager.PlayAnimationSequence("MsgWinAnimOpen", "MsgWinAnimClose");
accidentManager.uis.transform.Find("UI/转向").gameObject.SetActive(true);
}
}
}
}
}
}