Home c# Sensory control by the Unity

Sensory control by the Unity

Author

Date

Category

I am a novice game developer, so I constantly come across problems that I decide, but with this snag. In my game for Android, you need to move the main game object with your finger, without taking it off, only to the right or left. That is, imagine that there is some kind of bar of obstacles, and the object must be overcome, so it is necessary, if the finger left, then he is also left, and vice versa. I know about Touch, but how to agree movement, I do not understand. Thanks in advance! (It is desirable to work on the whole screen, as I understand the global touch)


Answer 1, Authority 100%

Here is a uniform movement behind the finger (without rotation)

if (input.touchcount & gt; 0)
    {
      transform.position = vector2.movetowards (transform.position
        Camera.Main.ScreentWorldPoint (Input.mousePosition), MoveSpeed);
    }

in MoveSpeed ​​Download Speed ​​”1f”

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions