Game Development Reference
In-Depth Information
public bool IsThinking() {
if (IsAiming) {
_lastTime = Time.time;
_isThinking = false;
return false;
}
float time;
if (_isThinking) { time = thinkingTime;}
else { time = walkingTime; }
if (Time.time >= (_lastTime + time)) {
_isThinking = !_isThinking;
_lastTime = Time.time;
}
return _isThinking;
}
4. The next step is the override function GetTargetDirecion() , which will
control all the movement direction of our enemy when it isn't aiming or shooting.
So, let's type it as follows:
// Unity JavaScript user:
protected override function GetTargetDirection () :
Vector3 {
var targetDirection : Vector3;
if (IsRun) {
targetDirection =
waypointsContainer.GetDirectionToPlayer(transform.position,
targetLookat.position);
} else {
if ((thinkingTime > 0) && IsThinking()) {
targetDirection = Vector3.zero;
} else {
targetDirection =
waypointsContainer.GetDirection(transform);
}
}
return targetDirection;
}
Search WWH ::




Custom Search