- Home /
Physics2D is colliding with nothing,Physics2D colliding with nothing
Hi,
I have started 2 days ago on programming and wanted to do something on Unity while I learn how to program.
The thing is that I apply a Physics2D.Raycast on a bullet and it leaves the weapon correctly going to right direction, but going to left direction is not leaving the weapon but it's actually triggering the log destroy bullet, so the bullet is getting destroyed at the same time than leaving the weapon.
if (Physics2D.Raycast(transform.position, Vector3.down, 0.1f))
{
Grounded = true;
}
else Grounded = false;
if (Physics2D.Raycast(transform.position, Vector3.left, 0.1f))
{
Grounded = true;
}
else Grounded = false;
if (Physics2D.Raycast(transform.position, Vector3.right, 0.1f))
{
Grounded = true;
}
else Grounded = false;
if (Grounded) {
AutoDestroyBullet();
Debug.Log("Destruido");
}
Curious thing is that it leaves the weapon correctly going to the left if i put 0.0001f, but it doesn't destroy itself colliding with a wall, so I think there's something with the float, but why would work on right but not on left?
Your answer
Follow this Question
Related Questions
How do I get characters to interact with each other? 1 Answer
Use full kinamatic contacts don't work with Physics2D.Raycast Unity 5.5 0 Answers
Make Physics2D.Raycast ignore triggers but Physics2D.OverlapBox doesn't? 0 Answers
Physics2D.Linecast and Physics2D.Raycast don't seem to return null 1 Answer