Exemplo n.º 1
0
    public static void BackupHelper(int EntityID, Vector3 awayFrom, int distance)
    {
        EntityAlive myEntity = GameManager.Instance.World.GetEntity(EntityID) as EntityAlive;

        if (myEntity == null)
        {
            return;
        }

        if (myEntity.moveHelper == null)
        {
            return;
        }

        Vector3 dirV   = myEntity.position - awayFrom;
        Vector3 vector = Vector3.zero;

        vector = myEntity.position + -new Vector3(awayFrom.x, 0f, awayFrom.z) * distance;

        // If you are blocked, try to go to another side.
        //vector = RandomPositionGenerator.CalcAway(myEntity, distance, distance,distance, awayFrom);
        myEntity.moveHelper.SetMoveTo(vector, false);

        myEntity.SetInvestigatePosition(vector, 20);


        // Move away at a hard coded speed of -4 to make them go backwards
        //  myEntity.speedForward = -4f;// Mathf.SmoothStep(myEntity.speedForward, -0.25f, 2 * Time.deltaTime);

        // Keep them facing the spot
        myEntity.SetLookPosition(awayFrom);
        myEntity.RotateTo(awayFrom.x, awayFrom.y, awayFrom.z, 30f, 30f);
    }