- Home /
The question is answered, right answer was accepted
Help with getting buildings blocks to appear on hit object's normals
Hi
I am working on a level editor where you can build with blocks basically. But I am having some troubles with getting the blocks to appear on the hit objects normals.
So currently I only have a raycast that shoots out from the mouse position and gets a hit position. Then I round that hit position to a full or half number. But this sometimes results in the block appearing in the hit object. So I added that it should add the hit.normal to it but that results in the block moving up one space when there is nothing there or simply just floating 1 meter above/next to the hit object.
So here's my code for the hit position stuff.
hitPos = hit.point + hit.normal;
hitPos.x = Mathf.Round(hitPos.x / 1) * 1;
hitPos.y = Mathf.Round(hitPos.y / 1) * 1;
hitPos.z = Mathf.Round(hitPos.z / 1) * 1;
Any help with this is greatly appreciated! I also need help with this ASAP since I have a tight deadline so the faster the better!
Thanks in advance!
Answer by RealMTG · May 21, 2016 at 02:04 PM
I eventually seem to have fixed it. I moved the level around a bit to make it all fit and then changed
hitPos = hit.point = hit.normal;
to
hitPos = hit.point + (hit.normal / 2);
Follow this Question
Related Questions
default cylinder to indicate hit.normal 1 Answer
Raycast Normal in Local Rotation? 1 Answer
How i can a normal vectors? 3 Answers
How can i get point reletive to hit.point 0 Answers
Click&Drag Misterious Disappearing! 1 Answer