Game Development Reference
In-Depth Information
// C# user:
protected override Vector3 GetTargetDirection () {
Vector3 targetDirection;
if (IsRun) {
targetDirection =
waypointsContainer.GetDirectionToPlayer(transform.position,
targetLookat.position);
} else {
if ((thinkingTime > 0) && IsThinking()) {
targetDirection = Vector3.zero;
} else {
targetDirection =
waypointsContainer.GetDirection(transform);
}
}
return targetDirection;
}
5. Next, we will create the Update() function. In this function, we will calculate
all the movement and behavior of our enemy. Let's add the following code:
// Unity JavaScript user:
function Update () {
if (!IS_GAMEOVER) {
ApplyGravity();
if (!IsJumping) {
if ((MotionState == MOTION_STATE.GROUND) ||
(MotionState == MOTION_STATE.AIM)) {
IsAiming = CanShoot();
} else {
IsAiming = false;
}
if (IsAiming) {
IsShowLaser(true);
if (_animator) {
Search WWH ::




Custom Search