Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Управление 3D игрой на смартфон

Discussion in 'Scripting' started by destern62, Nov 21, 2018.

  1. destern62

    destern62

    Joined:
    Nov 21, 2018
    Posts:
    2
    Ночами не сплю, днями горюю по поводу того, что не могу реализовать управление на мобильные телефоны. Возьмем к примеру игру PC Simulator. Замысел простой - джойстик на управление позицией персонажа в левой части экрана, а в правой область для ротации персонажа. Всё это происходит от первого лица. Как мне сделать примерно или точно такое же управление? Я пытался делать такое управление взяв за основу компонент Character Controller и смог сделать только джойстик и реализовать передвижение игрока, но не ротацию. Как мне сделать должное управление на смартфоны? Только не нужно писать что-либо с рекомендацией взять готовое управление со стандартных ассетов юнити. Может быть у вас есть заготовка подобного управления? Приму всё
     
  2. jvo3dc

    jvo3dc

    Joined:
    Oct 11, 2013
    Posts:
    1,520
    According to google translate:

    Manage 3D game on smartphone

    I do not sleep at night, I grieve for days that I can’t take control of my mobile phones. Take for example the PC Simulator game. The idea is simple - a joystick to control the position of the character on the left side of the screen, and in the right area for the rotation of the character. All this comes from the first person. How do I do about or exactly the same control? I tried to make such control taking the Character Controller component as a basis and could only make a joystick and realize the player's movement, but not rotation. How do I do proper management on smartphones? Just do not need to write anything with a recommendation to take control from the standard assets of the unit. Maybe you have a procurement of such management? I will accept everything
     
  3. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,514
  4. denis-andreevich

    denis-andreevich

    Joined:
    Aug 21, 2016
    Posts:
    50
    Hey. Have a similar question. I have a regular 2D game in which the character moves at the moment using the keyboard. I tried using this joystick set but get the stupid joystick behavior. Normally the joystick turns only to the right. When I try to pull it to the left, I need to go right outside the screen to do it. Maybe someone has a 100% working code to control a 2D character?
     
  5. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,514
    @denis-andreevich Generally this type of a thing is called a virtual analog joystick. It sounds like yours just has a zeroing problem, like your zero is located at the precise edge of the screen. Ideally the zero is located wherever your finger first touches, and everything is relative to that point, until you release and re-touch, at which point it resets to zero position to where your finger went down.

    There is one of these things in the standard Unity assets package but I actually wrote my own.

    Mine is called a VAButton (Virtual Analog Button) and it's available free here in my proximity buttons package, including some demos on how to use it, like a twin-stick shooter demo and other demos:

    https://bitbucket.org/kurtdekker/proximity_buttons

    https://github.com/kurtdekker/proximity_buttons

    https://gitlab.com/kurtdekker/proximity_buttons
     
  6. YouTuBeRPay

    YouTuBeRPay

    Joined:
    Nov 22, 2019
    Posts:
    1
    [QUOTE = "Курт-Деккер, должность: 4204561, участник: 225647"] [USER = 1164842] @ denis-andreevich [/ USER] Обычно этот тип вещей называется виртуальным аналоговым джойстиком. Похоже, у вас просто есть проблема с обнулением, как будто ваш экран находится на точном краю экрана. В идеале, когда ваш палец впервые касается, и все относительно этой точки, пока вы не отпустите и снова не коснетесь, и в этот момент он исчезнет в нулевом положении, где ваш палец опустился.

    В единстве есть одна из этих вещей, но я написал свою собственную.

    Мой называется VAButton (виртуальная аналоговая кнопка), и он доступен бесплатно здесь, в моем пакете кнопок, включая некоторые демонстрации того, как его использовать, например демонстрацию с двумя палками и другие демонстрации:

    https://bitbucket.org/kurtdekker/proximity_buttons

    https://github.com/kurtdekker/proximity_buttons

    https://gitlab.com/kurtdekker/proximity_buttons [/ QUOTE]
    ]
    Спасибо за бесполезную информацию)
    В списке вы указали, что работали на 4.6 примерно.
    А последний раз вы работали с проектом на 5.6 примерно.
    И знаете что обидно, на 5.2 уже не работает, все сломано!
    Это поможет мне в будущем.
     
  7. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,514
    Your google-translated quote from above:

    FIVE YEARS AGO (in 2015) the codebase was compatible with 4.6.5:

    Code (csharp):
    1. 8:20 AM 4/26/2015
    2.  
    3. Proximity Button Sets: this allows you to gracefully
    4. handle inaccurate finger-placement on touchscreen
    5. boolean buttons.
    6.  
    7. The demo scene will give you a simple use case.
    8.  
    9. This demo has been tested on Unity 4.6.5 but probably
    10. works on most recent flavors of Unity. Try it out!!

    If you look at the git commit log, it was upgraded on November 18, 2018. Please feel free to check out an earlier version if it suits you.

    Screen Shot 2020-03-11 at 10.27.05 AM.png