#collision with **if ()**

1 messages · Page 1 of 1 (latest)

dreamy ice
#

wow we can't just use if() ?

golden valve
dreamy ice
#

this can't work with the thing i'm making

golden valve
dreamy ice
#

i have to check collision many times in a frame

golden valve
dreamy ice
#

making a pong bot

#

the bot need to know where the ball should bounce

golden valve
#

just use void?

dreamy ice
#

in 1 frame

golden valve
#
{
    if (collision.collider.CompareTag("Enemy"))
    {
        // The object has collided with an enemy
    }
}```
#

this might work

dreamy ice
golden valve
#

just change some stuff

golden valve
#

not sure about this but this one migth work

#
{
    for (float i = 0; i < 1; i += 0.1f)
    {
        if (CheckForCollision())
        {
            // Collision detected
            break;
        }
        yield return new WaitForSeconds(0.1f);
    }
}

bool CheckForCollision()
{
    Ray ray = new Ray(transform.position, transform.forward);
    RaycastHit hitInfo;
    if (Physics.Raycast(ray, out hitInfo))
    {
        if (hitInfo.collider.CompareTag("Enemy"))
        {
            // The object has collided with an enemy
            return true;
        }
    }
    return false;
}```
dreamy ice
#

ho !

#

this can work i think

#

lets see

golden valve
dreamy ice
#

i just need if

golden valve
golden valve
dreamy ice
#

wait...

#

hmmmm...

#

YO WHAT DA

golden valve
#

?

#

@dreamy ice what's up?

dreamy ice
#

my balls are now rotating

golden valve
dreamy ice
#

(i talk about my game)

dreamy ice
golden valve
#

lmao

dreamy ice
#

BRAH WTF

#

what did you give me ?

#

i gonna do something diferent

#

thank for your helping !

golden valve
#

you can get a new idea lol

dreamy ice
#

(btw i'm no english so can i know what means "np")

golden valve
dreamy ice
#

ah! ok

golden valve
dreamy ice
#

no why ?

golden valve
dreamy ice
#

W H Y ?

golden valve