Answer the question
In order to leave comments, you need to log in
How to send a ray from the edge of an object?
Hello, we are making a kind of Tetris, and to determine whether the figure can fall further, we use
the following code
RaycastHit2D hitDown = Physics2D.Raycast(transform.position, Vector2.down, 0.5f);
Debug.Log(hitDown.collider.name);
Answer the question
In order to leave comments, you need to log in
I'll just leave my opinion here, suddenly it will help you to realize something) - what to do in Tetris check by "probing with a beam" is rather strange.
and how does it cover the options for the horizontal stick? rays from each edge? and if the stick stumbled on the PIK in the middle?
and specifically on the issue of
transform.position - will return you Pivot (Center of the object).
as such, you can set the extreme points separately in the figures, simply by placing a couple of child Transforms, and saving links to them in some kind of container.
If your shapes are a solid custom mesh, then you can also look towards
https://docs.unity3d.com/ScriptReference/Mesh-boun...
to find out the boundary points of the mesh.
well, having learned the points from which you want to send the ray - just substitute from the coordinate instead of transform.position.
if all of the above causes bewilderment and misunderstanding - then the English. and unity tutorials - earn bumps, that is, experience))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question