워리어 콤보 모작 개발일지

워리어콤보 개발일지 - Block 인식하기

다모아 2023. 9. 16. 18:17

Block을 인식하게 하고싶은데 계속 Block과 Wall 사이 공간을 클릭하거나 그러면 NullReference가 떠서

왜 뜨는지 뭔가 hit.collider가 null일 때 Debug도 찍어보고 location이 null인가? 해서 debug찍어보고 했었는데

그게 아니라 hit를 false 일 때 return 하게 만들었더니 해결이 되었다.

 

고치기 전

좌표가 안나오는데 안나오게 설정해놓은 것이고 저렇게 배경을 누르거나 블럭과 블럭 사이의 공간을 누르면 NullReference 오류가 떠서 생각을 오래했다..

 

고친 후

고친 모습


추가된 코드

hit가 false면 return 하게 만들었다.

그랬더니 nullreference가 없어졌다.

 

도움

https://stackoverflow.com/questions/42788004/physics2d-raycast-returning-null

 

Physics2D.Raycast returning null

I have a bit of a issue that has me super stumped here. I am going from Key codes , to mouse input - then it later become touch input, but first I want to figure out why i cant do this with just a ...

stackoverflow.com