- Home /
Translating an object along a line until it collides with other objects
I have a group of gameobjects with meshcolliders stacked in a "tower". I am looking for a way to - given a direction vector and an origin point - find the place where a new gameobject can be placed so that it collides with the meshcolliders already in the tower.
Here is an image to clarify what I am asking:
The grey shapes are objects already in the tower and the blue object is the object to be placed. Each frame I want to find this point of closest collision since the user can move around each frame.
Some ideas I've had is to start with the object at the camera's position and gradually translate it along the direction vector. Between each translation, collision with the tower objects is checked.
Answer by FortisVenaliter · May 04, 2016 at 05:41 PM
The idea you mentioned is the best way to do it, short of a hell of a lot of pretty advanced trig. Depending on your level of precision, you might want to check out Physics.BoxCast though.
Alright, Physics.BoxCast might be the best way to do it. Thanks for the input!
Your answer
Follow this Question
Related Questions
What else is to be done if players falls through the floor? 0 Answers
Physics.OverlapBox colliding with disabled MeshCollider 1 Answer
Detect if a non-trigger collider is inside another collider 1 Answer
Collision with Plane fails 0 Answers
BoxCollider get stuck when dragging over the border of two BoxColliders 1 Answer