コード例 #1
0
    private void HostState()
    {
        //Sets the last received destination only if cooldownBetweenRecalculation has reached 0 and if the new point is farther than the tolerance.
        currentCooldownLeft -= Time.deltaTime;
        if (currentCooldownLeft <= 0 && (oldDestination - nextDestination).magnitude > tolerance)
        {
            this.agent.isStopped = false;
            currentCooldownLeft  = cooldownBetweenRecalculations;
            agent.SetDestination(nextDestination);
            oldDestination = nextDestination;
            sphereV.StopLooking();
            coneV.StopLooking();
        }

        //Check if agent reached the destination, if yes calls the OnPathReached Event and then this won't be called again unless a new destination is set.
        if (!this.agent.isStopped && this.agent.hasPath && (this.transform.position - this.agent.destination).magnitude < tolerance)
        {
            this.agent.isStopped = true;
            sphereV.StartLooking();
            coneV.StartLooking();
        }
        Vector3 direction = this.agent.velocity.normalized;

        animController.Animation(direction.x, direction.z);
        //SendTransform();
    }
コード例 #2
0
    private void Update()
    {
        currentCooldownLeftBeforeRecalculation -= Time.deltaTime;
        if (currentCooldownLeftBeforeRecalculation <= 0)
        {
            this.agent.SetDestination(target.position);
        }

        Vector3 vel = this.agent.velocity.normalized;

        animController.Animation(vel.x, vel.z);

        CheckIfTargetInVision();
    }
コード例 #3
0
    public void ReceiveTransform(Vector3 pos, Quaternion rot) //USED BY MOVEMENTMANAGER
    {
        // Debug.Log("Enemy: " + this.GetComponent<GameNetworkObject>().NetworkId + "Position is: " + pos);

        startPos          = myTransform.position;
        startRot          = myTransform.rotation;
        interpolationTime = prediction.Predict(pos, rot, out endPos, out endRot, out speed);
        Vector3 normalizedSpeed = speed.normalized;

        animController.Animation(normalizedSpeed.x, normalizedSpeed.z);
        time = 0;
    }