- Home /
Bounds with Rotation: Getting y value of the point where its on the most left side of the collider (bounds.min.x) Note that the box collider has been rotated as well.
I understand that I can get the most low value of x of an object's collider using ().bounds.min.x, but on that point where the bound x value is the lowest, can I get its y value as well?
Any help?
Thanks
SInce Bounds represents a box, at runtime you could instantiate (at bounds.$$anonymous$$.x) a quad rotated and scaled so it fits the left face of the AABB. With OnCollisionEnter(Collision collision), you can get the contact points. Iterate through them and keep the lowest y. You don't need the quad anymore, so you can destroy it. For OnCollisionEnter to work, you must have rigidbody added.
Other more straighforward way is to loop though the vertex positions of your mesh (hopefully it isn't too large). For those vertices that are very close to bounds.$$anonymous$$.x, compare their y to keep the lowest.
Answer by Yeezyy · Dec 07, 2017 at 07:10 AM
Lowest left point for y =collider.bounds.center.y - collider.bounds.extend.y
Answer by Cheong · Dec 07, 2017 at 10:09 AM
thanks @Yeezyy and @Dragate for the replies, looks like I found a solution for getting the full coordinate :) I used the mathematical equation for circles, where r^2 = x^2 + y^2, where I get the radius first using collider size.x and y, then reapply into the equation again, by assigning x = collider.bounds.min.x, and r = radius found, and finally I can get the y value where the point is having min x on collider.
Yes it is a box collider, to get the vertices of the rotated boxcollider, then it will need the equation of a circle. Thanks :)
Your answer
Follow this Question
Related Questions
Mesh collider not working as expected 2 Answers
Get EXACT SkinnedMeshRenderer bounds 2 Answers
Bounds and unwanted offset 0 Answers
How to set parent collider equal to child collider visually? 2 Answers
Dynamically creating a box collider for an object with multiple, rotated, and scaled mesh renderers 0 Answers