# finger controlled game

I’d like to start a new project, I’ve been studying Unity for about 4 months now, and I need some help on it, I have a few questions, It’d be wonderful if someone could reply

1. I want to stop a rolling object when putting a finger in front of him (like the finger is a wall)
2. launch my character with a power and direction, like in the soccer stars mobile game but limit the angle of it so it cannot be shot backwards.
3. tagging a finger, attach raycast and check if there is a finger on the screen in front of the player, if yes then decrease speed until complete stop (which is when the finger already touched the object)

I recommend looking up ScreenPointToRay in the camera class. This will figure a point on the screen is in the world, basically. At the point it returns back to you, you can move / instantiate some invisible collider which stops your object’s rigidbody (Unity physics) from rolling.

I recommend looking up rigidbody, since it will be useful to you in this part since you’ll be able to add force with a direction to the rigidbody on the object. I’m sure there’s a touch and release function that have a way of obtaining screen positions, so you can use the distance of that to get your force and (point2-point1).normalized for the direction. Or simple use point2-point1 for both (if that works that way, I think?). By checking comparing the x coordinates of the touch and release points, you can check if the end point is further back than the start point which, if you’re rolling from left to right, would be a backwards angle.

Is this related to #1? So a finger in front of the player should slow them, and if they don’t fully stop before hitting the finger/wall, then they stop? If so, the easiest way to do this could be to compare the x coordinates of the finger and the player.

1 Like