Answer the question
In order to leave comments, you need to log in
Physics2D.Raycast not working, why?
In general, the code that worked properly stopped working, I can’t figure out what’s wrong. hit2Dir always has a value, hit2.point = (0,0), and with hit2.collider.name an error occurs (because the raycast does not hit anywhere, although there is an object above it), when hit3 always works. What could be the problem?
hit2 = Physics2D.Raycast(posOfHit, hit2Dir, maskGround);
print("hit2.point: " + hit2.point /*+ "hit2.collider: " + hit2.collider.name*/);
hit3 = Physics2D.Raycast(posOfHit, hit2Dir * -1, maskGround);
print("hit3.point: " + hit3.point + "hit3.collider: " + hit3.collider.name);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question