Neodroid  0.2.0
Machine Learning Environment Prototyping Tool
AngularVelocityEvaluation.cs
Go to the documentation of this file.
1 using UnityEngine;
2 
3 namespace droid.Runtime.Prototyping.Evaluation {
7  [AddComponentMenu(EvaluationComponentMenuPath._ComponentMenuPath
8  + "AngularVelocity"
9  + EvaluationComponentMenuPath._Postfix)]
11  [SerializeField] bool _penalty = false;
12  [SerializeField] Rigidbody _rigidbody = null;
13 
17  public override float InternalEvaluate() {
18  if (this._penalty) {
19  if (this._rigidbody) {
20  return -this._rigidbody.angularVelocity.magnitude;
21  }
22  }
23 
24  if (this._rigidbody) {
25  return 1 / (this._rigidbody.angularVelocity.magnitude + 1);
26  }
27 
28  return 0;
29  }
30 
33  public override void InternalReset() { }
34 
38  protected override void PostSetup() {
39  if (this._rigidbody == null) {
40  this._rigidbody = FindObjectOfType<Rigidbody>();
41  }
42  }
43  }
44 }