Game Development Reference
In-Depth Information
_isHitRadius = true;
_wayIndex = _nextIndex;
if (isRandom) {
var _randomWay : int =
Mathf.FloorToInt(Random.value * _wayLength);
if (_wayLength > 1) {
while (_wayIndex == _randomWay) {
_randomWay =
Mathf.FloorToInt(Random.value * _wayLength);
}
}
_nextIndex = _randomWay;
} else {
_nextIndex = (_nextIndex + 1) % _wayLength;
}
}
} else {
_isHitRadius = false;
}
var currentPosition : Vector3 = new Vector3
(myTransform.position.x,
waypoints[_nextIndex].transform.position.y,
myTransform.position.z);
_direction =
(waypoints[_nextIndex].transform.position -
currentPosition).normalized;
return _direction;
}
// C# user:
public Vector3 GetDirection (Transform myTransform)
{
Vector3 offset = myTransform.position -
waypoints[_nextIndex].transform.position;
float length = offset.sqrMagnitude;
float sqrDistance = radius*radius;
if (length <= sqrDistance) {
Search WWH ::




Custom Search