#collision with **if ()**
1 messages · Page 1 of 1 (latest)
did my code work?
this can't work with the thing i'm making
what are you working on?
i have to check collision many times in a frame
why?
just use void?
in 1 frame
{
if (collision.collider.CompareTag("Enemy"))
{
// The object has collided with an enemy
}
}```
this might work
void do only 1 in a frame
just change some stuff
hmm
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;
}```
if yield doesn't work change it to field and try
i just need if
did my code work?
my balls are now rotating
so it worked?
(i talk about my game)
no
lmao
BRAH WTF
what did you give me ?
i gonna do something diferent
thank for your helping !
(btw i'm no english so can i know what means "np")
no problem
ah! ok
do you do 3d game development by the way?
no why ?
ahh then never mind
W H Y ?
never mind