Hunter
5 年前
当前提交
079bf01a
共有 13 个文件被更改,包括 443 次插入 和 316 次删除
-
3UnitySDK/Assets/ML-Agents/Examples/SharedAssets/Scripts/AgentCubeGroundCheck.cs
-
3UnitySDK/Assets/ML-Agents/Examples/WallJump/Brains/BigWallJumpLearning.asset
-
3UnitySDK/Assets/ML-Agents/Examples/WallJump/Brains/SmallWallJumpLearning.asset
-
5UnitySDK/Assets/ML-Agents/Examples/WallJump/Brains/WallJumpPlayer.asset
-
230UnitySDK/Assets/ML-Agents/Examples/WallJump/Prefabs/WallJumpArea.prefab
-
295UnitySDK/Assets/ML-Agents/Examples/WallJump/Scenes/WallJump.unity
-
19UnitySDK/Assets/ML-Agents/Examples/WallJump/Scripts/WallJumpAcademy.cs
-
112UnitySDK/Assets/ML-Agents/Examples/WallJump/Scripts/WallJumpAgent.cs
-
9UnitySDK/ProjectSettings/EditorSettings.asset
-
2UnitySDK/csharp_timers.json
-
2csharp_timers.json
-
73UnitySDK/Assets/ML-Agents/Examples/SharedAssets/Scripts/AgentCubeMovement.cs
-
3UnitySDK/Assets/ML-Agents/Examples/SharedAssets/Scripts/AgentCubeMovement.cs.meta
|
|||
{"count":1,"self":75.7271104,"total":89.109481,"children":{"AgentResetIfDone":{"count":4360,"self":0.21384199999999998,"total":0.21384199999999998,"children":null},"AgentSendState":{"count":4360,"self":1.359667,"total":3.765707,"children":{"CollectObservations":{"count":34896,"self":2.40604,"total":2.40604,"children":null}}},"BrainDecideAction":{"count":4360,"self":6.1270219999999993,"total":6.1270219999999993,"children":null},"AcademyStep":{"count":4360,"self":0.119783,"total":0.119783,"children":null},"AgentAct":{"count":4360,"self":3.155154,"total":3.155154,"children":null}}} |
|||
{"count":1,"self":59.143136,"total":59.827309,"children":{"AgentResetIfDone":{"count":2884,"self":0.143195,"total":0.143195,"children":null},"AgentSendState":{"count":2884,"self":0.131877,"total":0.223355,"children":{"CollectObservations":{"count":962,"self":0.09147799999999999,"total":0.09147799999999999,"children":null}}},"BrainDecideAction":{"count":2884,"self":0.097074,"total":0.097074,"children":null},"AcademyStep":{"count":2884,"self":0.087388,"total":0.087388,"children":null},"AgentAct":{"count":2884,"self":0.13186399999999998,"total":0.13186399999999998,"children":null}}} |
|
|||
{"count":1,"self":734.6514432,"total":19807.115766,"children":{"AgentResetIfDone":{"count":986659,"self":10.4867776,"total":10.486778,"children":null},"AgentSendState":{"count":986659,"self":64.5328,"total":294.04925099999997,"children":{"CollectObservations":{"count":7893288,"self":229.51644159999998,"total":229.51645399999998,"children":null}}},"BrainDecideAction":{"count":986659,"self":18022.7817472,"total":18022.782152,"children":null},"AcademyStep":{"count":986659,"self":6.2750179999999993,"total":6.2750179999999993,"children":null},"AgentAct":{"count":986659,"self":738.8690944,"total":738.86911,"children":null}}} |
|||
{"count":1,"self":325.8655232,"total":11325.855853,"children":{"AgentResetIfDone":{"count":461409,"self":4.413044,"total":4.413044,"children":null},"AgentSendState":{"count":461409,"self":29.0895232,"total":133.040449,"children":{"CollectObservations":{"count":3691272,"self":103.9509248,"total":103.950925,"children":null}}},"BrainDecideAction":{"count":461409,"self":10831.9637504,"total":10831.963456,"children":null},"AcademyStep":{"count":461409,"self":2.617991,"total":2.617991,"children":null},"AgentAct":{"count":461409,"self":27.953027199999998,"total":27.953025999999998,"children":null}}}ldren":null}}} |
|
|||
using UnityEngine; |
|||
|
|||
namespace MLAgents |
|||
{ |
|||
public class AgentCubeMovement : MonoBehaviour |
|||
{ |
|||
[Header("RUNNING")] public ForceMode runningForceMode = ForceMode.Impulse; |
|||
//speed agent can run if grounded
|
|||
public float agentRunSpeed = 20; |
|||
//speed agent can run if not grounded
|
|||
public float agentRunInAirSpeed = 10f; |
|||
|
|||
[Header("IDLE")] |
|||
//coefficient used to dampen velocity when idle
|
|||
//the purpose of this is to fine tune agent drag
|
|||
//...and prevent the agent sliding around while grounded
|
|||
//0 means it will instantly stop when grounded
|
|||
//1 means no drag will be applied
|
|||
public float agentIdleDragVelCoeff = .85f; |
|||
|
|||
[Header("BODY ROTATION")] |
|||
//body rotation speed
|
|||
public float agentRotationSpeed = 7f; |
|||
|
|||
[Header("JUMPING")] |
|||
//upward jump velocity magnitude
|
|||
public float agentJumpVelocity = 15f; |
|||
|
|||
[Header("FALLING FORCE")] |
|||
//force applied to agent while falling
|
|||
public float agentFallingSpeed = 50f; |
|||
|
|||
public void Jump(Rigidbody rb) |
|||
{ |
|||
Vector3 velToUse = rb.velocity; |
|||
velToUse.y = agentJumpVelocity; |
|||
rb.velocity = velToUse; |
|||
} |
|||
|
|||
public void RotateBody(Rigidbody rb, Vector3 rotationAxis) |
|||
{ |
|||
rb.MoveRotation(rb.rotation * Quaternion.AngleAxis(agentRotationSpeed, rotationAxis)); |
|||
} |
|||
|
|||
public void RunOnGround(Rigidbody rb, Vector3 dir) |
|||
{ |
|||
var vel = rb.velocity.magnitude; |
|||
float adjustedSpeed = Mathf.Clamp(agentRunSpeed - vel, 0, agentRunSpeed); |
|||
rb.AddForce(dir.normalized * adjustedSpeed, |
|||
runningForceMode); |
|||
} |
|||
|
|||
public void RunInAir(Rigidbody rb, Vector3 dir) |
|||
{ |
|||
var vel = rb.velocity.magnitude; |
|||
float adjustedSpeed = Mathf.Clamp(agentRunInAirSpeed - vel, 0, agentRunInAirSpeed); |
|||
rb.AddForce(dir.normalized * adjustedSpeed, |
|||
runningForceMode); |
|||
} |
|||
|
|||
public void AddIdleDrag(Rigidbody rb) |
|||
{ |
|||
rb.velocity *= agentIdleDragVelCoeff; |
|||
} |
|||
|
|||
public void AddFallingForce(Rigidbody rb) |
|||
{ |
|||
rb.AddForce( |
|||
Vector3.down * agentFallingSpeed, ForceMode.Acceleration); |
|||
} |
|||
} |
|||
|
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 7dbad9f11d9f4b2884e5f8fd66c81426 |
|||
timeCreated: 1571951124 |
撰写
预览
正在加载...
取消
保存
Reference in new issue