Game Development Reference
In-Depth Information
// Unity JavaScript user:
function Start () {
var collider : Collider = _targetTransform.collider;
_centerOffset = collider.bounds.center -
_targetTransform.position;
}
// C# user:
void Start () {
Collider collider = _targetTransform.collider;
_centerOffset = collider.bounds.center -
_targetTransform.position;
}
5. Next, we will create the AngleDistance() function to get the angle distance
between the current angle and target; let's add the following code:
// Unity JavaScript user:
function AngleDistance ( a : float, b : float) :
float {
a = Mathf.Repeat(a, 360);
b = Mathf.Repeat(b, 360);
return Mathf.Abs(b - a);
}
// C# user:
float AngleDistance (float a, float b) {
a = Mathf.Repeat(a, 360);
b = Mathf.Repeat(b, 360);
return Mathf.Abs(b - a);
}
Note
Mathf.Repeat(t,l) is the function that we can use to loop the t value but
not higher than l and not lower than 0 .
Search WWH ::




Custom Search