Esempio n. 1
0
 void Update()
 {
     if (transform.position.y < 0 || !TerrainScript.isInsidePlane(transform.position))
     {
         explode();
     }
 }
Esempio n. 2
0
 void RecalculateTargetPosition()
 {
     do
     {
         targetPosition   = transform.position + Random.insideUnitSphere * wanderRadius;
         targetPosition.y = 0.5f;
     } while (!TerrainScript.isInsidePlane(targetPosition));
 }
Esempio n. 3
0
    protected void MoveTowardsWithoutRotate(Vector3 direction)
    {
        Vector3 nextPosition = direction.normalized * movementSpeed * Time.deltaTime;

        if (TerrainScript.isInsidePlane(transform.position + nextPosition))
        {
            transform.position += nextPosition;
        }
    }
Esempio n. 4
0
    void RecalculateTargetPosition()
    {
        do
        {
            targetPosition   = transform.position + UnityEngine.Random.insideUnitSphere * wanderRadius;
            targetPosition.y = 0.5f;
        } while (!TerrainScript.isInsidePlane(targetPosition));

        Vector3 direction = targetPosition - transform.position;

        animator.SetFloat("y", -direction.z);
        animator.SetFloat("x", direction.x);
        animator.SetBool("moveHorizontal", Mathf.Abs(direction.x) > Mathf.Abs(direction.z));
    }
Esempio n. 5
0
    void SpawnPrefab()
    {
        float   random = Random.Range(0, totalRate);
        Vector3 spawnPoint;

        do
        {
            spawnPoint = transform.position + Random.insideUnitSphere * spawnRadius;
        } while (!TerrainScript.isInsidePlane(spawnPoint));

        spawnPoint.y = 0.5f;


        foreach (PrefabRate generatedPrefab in generatedPrefabs)
        {
            random -= generatedPrefab.rate;
            if (random <= 0)
            {
                GameObject.Instantiate(generatedPrefab.prefab, spawnPoint, Quaternion.identity);
            }
        }
    }