i want a function in my mobile game through which user can move his finger across the screen to make an object.the object can be any shape that user makes like a line a box or circle.the object should also have physical properties.Very similar to like the game Brain it on.
its seems simple but as i am a beginner i dont know the exact way to do so
kindly plz give any link to a tutorial or explain yourself.
Thanks
Hi! Well regarding your input you can check this :
- Learn game development w/ Unity | Courses & tutorials in game design, VR, AR, & Real-time 3D | Unity Learn
- Unity - Manual: Mobile device input
Scripting:
For a line :
- Return the initialPos of the screen where you touched.
- Return the endPos of the screen where you touched.
- Create a line renderer (You first need to create a GO or include the Line to a current GO)
Unity - Manual: Line Renderer component - Assign the initialPos and endPos to the Linerenderer .
- Set the linerenderer to useWorldSpace = false
- Assign material you want
- Add Rigidbody to the GO that contains the line to add physics properties.
- Add what you want etc.
For a box, circle
- Get the pos of the touch
- Create a primitiveObject in that pos
Unity - Scripting API: GameObject.CreatePrimitive - Add Rigidbody for physics