Exemplo n.º 1
0
    public override void Use()
    {
        PaintBall   ball = Instantiate(m_paintball, m_spawnPosition.position, Quaternion.identity);
        Rigidbody2D rb2d = ball.GetComponent <Rigidbody2D>();

        Vector2 rand = new Vector2(Random.Range(-1f, 1f), 1);

        rb2d.AddForce(m_baseForce * rand, ForceMode2D.Impulse);

        SFXManager.Instance.PlaySound(m_useSounds[Random.Range(0, m_useSounds.Length)]);
    }
Exemplo n.º 2
0
    private void OnTriggerEnter(Collider other)
    {
        if (stuck)
        {
            return;
        }

        //as long as it didnt collide with a player, or another paint ball
        Player player = other.GetComponentInParent <Player>();

        if (!player)
        {
            PaintBall ball = other.GetComponentInParent <PaintBall>();
            if (!ball)
            {
                rigidbody.isKinematic = true;
                stuck = true;
                Destroy(gameObject, 30f);
            }
        }
    }
Exemplo n.º 3
0
    IEnumerator Spawn()
    {
        Vector3 center = Vector3.Lerp(targetLeft.position, targetRight.position, Random.value);
        Vector3 target = Vector3.Lerp(center, targetForward.position, Random.value);

        transform.LookAt(target);

        yield return(null);

        PaintBall ball = Instantiate(prefab);

        ball.transform.SetParent(paintPool);
        ball.transform.position = transform.position;
        ball.gameObject.SetActive(true);

        yield return(null);

        float force = Random.value * (maxForce - minForce) + minForce;

        ball.AddForce(transform.forward * force);
    }