Ejemplo n.º 1
0
    private void Update()
    {
        // Get axis input for movement.
        Vector3 moveInput = new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical"));

        isMoving = moveInput != Vector3.zero;
        anim.SetBool("isMoving", isMoving);
        moveVelocity = moveInput.normalized * moveSpeed;

        // TODO: CHANGE INPUT KEY ACCORDINGLY
        if (Input.GetKeyDown(KeyCode.Space))
        {
            if (!placedFirstPlant)
            {
                int        random = Random.Range(1, 3 + 1);
                GameObject spawn  = PrefabManager.instance.InitPrefab(random, transform.position);
                placedFirstPlant = true;
                return;
            }

            //if (currentlyHolding.GetComponent<Plant>())
            //{

            //}

            Collider[] hits = Physics.OverlapSphere(transform.position, interactionRadius);
            foreach (Collider hit in hits)
            {
                Debug.Log("possible interaction with:" + hit.gameObject.name);
                Interactible interactible = hit.gameObject.GetComponent <Interactible>();
                if (interactible != null)
                {
                    interactible.InteractWith();
                }
            }
        }
    }