- Home /
check for object placeability,check for placeability,
hi
I'm working on a object placing script: basically, when you click on anything with a collider, in the scene, my script instances an object, aligned to the surface you clicked on. pretty easy till now.
The problem is : I'm stuck at determing the item placeability.
The twisted way i'm trying to achieve it, is by casting 4 rays, from the bottom vertices of the prefab, and then check if all of them land on the same even surface.
Debug.DrawLine(hit.point+offsetx, (hit.point+offsetx) - hit.normal , Color.red, 2, false);
Debug.DrawLine(hit.point-offsetx, (hit.point-offsetx) - hit.normal , Color.red, 2, false);
Debug.DrawLine(hit.point+offsetz, (hit.point+offsetz) - hit.normal , Color.red, 2, false);
Debug.DrawLine(hit.point-offsetz, (hit.point-offsetz) - hit.normal , Color.red, 2, false);
But I had no luck in determining these 4 vertices, also tried with renderer.bounds or mesh.bounds related calculations, and it works great when item is facing Y but it just stops working when I change axis. any advice on a better method or a better way to determine the bottom vertexes of the mesh as I try to instance it on a surface?
thank you very much for your ideas
Your answer
Follow this Question
Related Questions
Building objects in-game 0 Answers
Difference between dynamic batching and gpu instancing? 1 Answer
when should Mesh.Optimize() be called 1 Answer
Renderer Bounds 3 Answers