Disclaimer: I am new to unity and i am fooling around with a small first prototype
I am making a small game 2d where you have to shoot a ball through goals.
The goals are given by a line between pairs of markers and these markers are moving (changing the orientation of the goal, changing the size of the goal).
My question is how to check if the ball crossed a given line (bonus - the line is “moving”, the markers should be able to accelerate slow down, it would be perfect if they could be given by the line between rigid bodies).
Is this possible? And how would i approach it.
What i have at the moment is the ball (3d sphere, rigid body, sphere collider, physics material) and i am shooting the ball by mouse down, drag, let lose. The ball bounces around and the goal markers are given by other bodies (also spheres, sphere collider, rigid body) and i am moving the goal markers around.
Thanks for helping a beginner out,
richard
thanks a lot for your help - i will try to create a plane and collide against it.
– richard.kI got it to work with a variation of your code snippet and small capsule colliders. I use a collision layer for the capsules and let them collide with a small ball inside of the real ball. The capsules are aligned between the goals. It works perfectly. (Planes where too expensive)
– richard.k