浏览代码

update strafe code. getkeydown not working in agent script

/hh-develop-fps_game_project
HH 4 年前
当前提交
c1af1229
共有 2 个文件被更改,包括 12 次插入5 次删除
  1. 11
      Project/Assets/ML-Agents/Examples/FPS_Game/Scenes/FPS_Game.unity
  2. 6
      Project/Assets/ML-Agents/Examples/FPS_Game/Scripts/FPSAgent.cs

11
Project/Assets/ML-Agents/Examples/FPS_Game/Scenes/FPS_Game.unity


m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1828481691}
m_LocalRotation: {x: 8.9741037e-10, y: 0.99454474, z: -0.104311325, w: 0.000000008556258}
m_LocalRotation: {x: -8.9741037e-10, y: 0.99454474, z: -0.104311325, w: -0.000000008556258}
m_LocalPosition: {x: 9.70142, y: 1.9999999, z: 6.4973907}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []

propertyPath: strafeCoolDownDuration
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5337721584620702641, guid: 0058b366f9d6d44a3ba35beb06b0174b,
type: 3}
propertyPath: allowKeyboardInput
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5337721584620702644, guid: 0058b366f9d6d44a3ba35beb06b0174b,
type: 3}
propertyPath: groundCheckBoxSize.x

- target: {fileID: 6056307872446210073, guid: 0058b366f9d6d44a3ba35beb06b0174b,
type: 3}
propertyPath: m_LocalRotation.y
value: -0.000000008556258
value: 0.000000008556258
value: 8.9741037e-10
value: -8.9741037e-10
objectReference: {fileID: 0}
- target: {fileID: 6056307872446210073, guid: 0058b366f9d6d44a3ba35beb06b0174b,
type: 3}

6
Project/Assets/ML-Agents/Examples/FPS_Game/Scripts/FPSAgent.cs


var shootAxis = act[3];
m_Shoot = shootAxis > 0 ? true : false;
m_CubeMovement.RunOnGround(m_AgentRb, m_Cam.transform.TransformDirection(new Vector3(rightAxis, 0, forwardAxis)));
m_CubeMovement.RunOnGround(m_AgentRb, m_Cam.transform.TransformDirection(new Vector3(0, 0, forwardAxis)));
m_CubeMovement.Strafe(transform.right * rightAxis);
if (shootAxis > 0)
{
// gunController.Shoot();

{
var contActionsOut = actionsOut.ContinuousActions;
contActionsOut[0] = Input.GetKey(KeyCode.W) ? 1 : Input.GetKey(KeyCode.S) ? -1 : 0; //inputV
contActionsOut[1] = Input.GetKey(KeyCode.E) ? 1 : Input.GetKey(KeyCode.Q) ? -1 : 0; //inputH
contActionsOut[1] = Input.GetKeyDown(KeyCode.E) ? 1 : Input.GetKeyDown(KeyCode.Q) ? -1 : 0; //inputH
// print(contActionsOut[1]);
contActionsOut[2] = Input.GetKey(KeyCode.D) ? 1 : Input.GetKey(KeyCode.A) ? -1 : 0; //rotate
contActionsOut[3] = Input.GetKey(KeyCode.Space) ? 1 : 0; //shoot

正在加载...
取消
保存