My raycast consider all position floor

In the video, the preview only shows when mouse hits the floor.
My preview is always On as soon as i do the drag. So I checked what it hit and etc, it turns out the ray always think it hit the floor for some reason. (I used Debug.Log(hit.collider.transform.localScale) to debug, and found out the log scale is always the same as my floor.)
The preview location is correct so I dont think my ray is off, and I checked my floor setting is the same as the video.
Im really confused.

Hi there, the Floor Mask is set to Floor only on the building button? Do you want to share you layer setup here?

Yea, I also tried changing floor Layer Mask to something else, and the preview stopped showing at all.

I also want to point out that, my HP bar using the FaceCamera script is also off on the UI.
HP bar is always facing the camera, but the position is off(HP bar isnt right on top of the unit) when the unit is facing different directions
(i didnt use the tank asset as unit, so I thought its my asset’s model problem.)
Now I think about it, they might be caused by the same thing.

here is my camera and floor settings:


What about the building button prefab, does that have layer mask set to floor?

Yes the Floor Mask is set to Floor. (if i change it to other, i dont see building show up at all, so that part is correct.)
I think its taking the non floor area floor.

Is it possible the ray is just actually hitting the floor? Can you show a picture of not hitting the floor but still on?

Okay, if you want me to take a look, upload your project here and I can check it out:
https://gdev.tv/projectupload

I just found out what went wrong…
so my floor’s box collider setting i have size 20,1,20, i thought it needs to match the scale of transform
apparently it multiply the size of scale by 20 and 20…

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms