Hello Folks,
How could I make a system which every time the player draw a circle at the screen, everything inside the circle would be destroyed?
*This is for a mobile game.
thanks
Hello Folks,
How could I make a system which every time the player draw a circle at the screen, everything inside the circle would be destroyed?
*This is for a mobile game.
thanks
Do you have software in place to detect if the player drew a circle? If so you can just use the Physics and raycast via a SphereCast from the camera out towards a certain distance. Use the Radius of the circle the player drew as the constraint and everything within the circle you can call Destroy on the gameObject
I don’t have any software to detect if the player has drawn a circle.Is there any software for that? It’s one of my big problems.
Where is is your problem exactly?
Detecting the user input, drawing the circle or only detecting what’s inside the circle?
My problem is just to detect when the player has made an interception, and after that, take a list of objects inside this circle.
I guess the curve made by the user is modeled as small line segments. To find where the curve has interceptions, you would need to find which line segments intercept and the compute their interception point.
After that, you need to build up the closed polygon. Then it boils down to test for polygon intersections. If you object can be consider as point. Then it is goes a bit simpler: you test if a point is inside a polygon.
This kind of problem is studied in Computational Geometry. Google the term if you want to learn more about it.
I gonna llook at this term. Thanks.
I’d create 4 float variables (or 4 arrays if you support multitouch), xMin, xMax, yMin, yMax. When touchPhase.Began is called, give xMin, xMax the x position of the touch, and yMin, yMax the Y position of the touch. Store the initial position as well.
Every frames that touchPhase.Moved is called, compare the position against your 4 values. If the X position returned when touchPhase.Moved is called is smaller than xMin, store it as xMin, if larger than xMax, store it as xMax, etc…
When the finger is lifted, check if it’s close enough to the initial starting point (whatever you feel is appropriate for your game - compare distance with the stored initial touch position). If it is, create your circle at the center of xMin and xMax, and the center of yMin and yMax. Give it the diameter of the smaller distance between either xMin and xMax or yMin and yMax.
This is untested, but I think it should work. It’s probably not the fanciest/most accurate, but I guess it all depends on what your needs are.