- Home /
Object motions in race game?
Hi all,
I am making a small game. in that i don't know how to write code to tap for tablet. i want object to move left side when we tap on left side and right side when we tap on right side.
http://www.appsapk.com/speedcar/
After installing apk u can get my question.
Is there any special library to access for that.
Thanks & Regards
Shankar
No one is going to download and install something to help you. You need to put some more time in yourself until at least you can ask it without having people figure out your question to.
Ok.. i have already informed everything in question itself. its just only to people for better understanding.
Answer by robertbu · Apr 26, 2013 at 01:00 PM
Your question is vague. See Input.touches for the interface to handle touch input in Unity. There are third-party tools that abstract away mouse/touch differences making it easier to develop for touch devices. We use FingerGestures which can be found in the Asset Store. TouchKit from Prime31 has been mention on this list. It is free and can be found here. As for the game, moving left and right will depend on how you move your vehicles: translation, rigidbody physics, or character controller. In addition, most racing games have some curves and needs some sort of path following. A free place to start with paths is with iTween and the PutOnPath() and PointOnPath() methods.
Thanx a lot $$anonymous$$r. Robertbu for ur response. You were only telling me about gestures and mouse/touches. But accutually what I need is that, for suppose if I have a cube on my screen, If I tilt my tablet to right, the cube should move to right and the same with left. I want this to work in Unity 3D. Are there any special methods?? Even though I have tried many ways I din't find any solution for it. Thanx in advance
You need to use Input.acceleration - which is the accelerometer reading. Normally that is a vector of magnitude 1 for a device lying at rest, the vector points into the screen.
When you tilt the device it's still pointing downwards, so you can work out the angle that the device is at using that.