Neodroid  0.2.0
Machine Learning Environment Prototyping Tool
EulerTransformActuator.cs
Go to the documentation of this file.
4 using UnityEngine;
5 
6 namespace droid.Runtime.Prototyping.Actuators {
10  [AddComponentMenu(ActuatorComponentMenuPath._ComponentMenuPath
11  + "EulerTransform"
12  + ActuatorComponentMenuPath._Postfix)]
16  [SerializeField]
17  protected string _Layer_Mask = "Obstructions";
18 
21  [SerializeField]
22  protected bool _No_Collisions = true;
23 
26  [SerializeField]
27  protected Space _Relative_To = Space.Self;
28 
29  string _rot_x;
30  string _rot_y;
31  string _rot_z;
32 
33  string _x;
34  string _y;
35  string _z;
36 
40  public override string PrototypingTypeName { get { return "Transform"; } }
41 
45  protected override void Setup() {
46  this._x = this.Identifier + "X_";
47  this._y = this.Identifier + "Y_";
48  this._z = this.Identifier + "Z_";
49  this._rot_x = this.Identifier + "RotX_";
50  this._rot_y = this.Identifier + "RotY_";
51  this._rot_z = this.Identifier + "RotZ_";
52  }
53 
57  protected override void RegisterComponent() {
58  this.Parent =
59  NeodroidUtilities.RegisterComponent((IHasRegister<IActuator>)this.Parent, (Actuator)this, this._x);
60  this.Parent =
61  NeodroidUtilities.RegisterComponent((IHasRegister<IActuator>)this.Parent, (Actuator)this, this._y);
62  this.Parent =
63  NeodroidUtilities.RegisterComponent((IHasRegister<IActuator>)this.Parent, (Actuator)this, this._z);
64  this.Parent =
65  NeodroidUtilities.RegisterComponent((IHasRegister<IActuator>)this.Parent, (Actuator)this, this._rot_x);
66  this.Parent =
67  NeodroidUtilities.RegisterComponent((IHasRegister<IActuator>)this.Parent, (Actuator)this, this._rot_y);
68  this.Parent =
69  NeodroidUtilities.RegisterComponent((IHasRegister<IActuator>)this.Parent, (Actuator)this, this._rot_z);
70  }
71 
76  protected override void InnerApplyMotion(IMotion motion) {
77  if (motion.ActuatorName == this._x) {
78  this.transform.Translate(Vector3.left * motion.Strength, this._Relative_To);
79  } else if (motion.ActuatorName == this._y) {
80  this.transform.Translate(-Vector3.up * motion.Strength, this._Relative_To);
81  } else if (motion.ActuatorName == this._z) {
82  this.transform.Translate(-Vector3.forward * motion.Strength, this._Relative_To);
83  } else if (motion.ActuatorName == this._rot_x) {
84  this.transform.Rotate(Vector3.left, motion.Strength, this._Relative_To);
85  } else if (motion.ActuatorName == this._rot_y) {
86  this.transform.Rotate(Vector3.up, motion.Strength, this._Relative_To);
87  } else if (motion.ActuatorName == this._rot_z) {
88  this.transform.Rotate(Vector3.forward, motion.Strength, this._Relative_To);
89  }
90  }
91  }
92 }