Virtual joystick implementation for mobile game

NOVASOLUTIONS.TECHNOLOGY is engaged in the development, support and maintenance of iOS, Android, PWA mobile applications. We have extensive experience and expertise in publishing mobile applications in popular markets like Google Play, App Store, Amazon, AppGallery and others.
Development and support of all types of mobile applications:
Information and entertainment mobile applications
News apps, games, reference guides, online catalogs, weather apps, fitness and health apps, travel apps, educational apps, social networks and messengers, quizzes, blogs and podcasts, forums, aggregators
E-commerce mobile applications
Online stores, B2B apps, marketplaces, online exchanges, cashback services, exchanges, dropshipping platforms, loyalty programs, food and goods delivery, payment systems.
Business process management mobile applications
CRM systems, ERP systems, project management, sales team tools, financial management, production management, logistics and delivery management, HR management, data monitoring systems
Electronic services mobile applications
Classified ads platforms, online schools, online cinemas, electronic service platforms, cashback platforms, video hosting, thematic portals, online booking and scheduling platforms, online trading platforms

These are just some of the types of mobile applications we work with, and each of them may have its own specific features and functionality, tailored to the specific needs and goals of the client.

Showing 1 of 1 servicesAll 1735 services
Virtual joystick implementation for mobile game
Simple
from 1 business day to 3 business days
FAQ
Our competencies:
Development stages
Latest works
  • image_mobile-applications_feedme_467_0.webp
    Development of a mobile application for FEEDME
    756
  • image_mobile-applications_xoomer_471_0.webp
    Development of a mobile application for XOOMER
    624
  • image_mobile-applications_rhl_428_0.webp
    Development of a mobile application for RHL
    1052
  • image_mobile-applications_zippy_411_0.webp
    Development of a mobile application for ZIPPY
    947
  • image_mobile-applications_affhome_429_0.webp
    Development of a mobile application for Affhome
    862
  • image_mobile-applications_flavors_409_0.webp
    Development of a mobile application for the FLAVORS company
    445

Implementing a Virtual Joystick for Mobile Games

A virtual joystick seems simple until the first playtest. Eight lines of code using Input.GetTouch and Vector2.Normalize work on the developer's device. On a 5.4" phone in landscape mode, your thumb covers the joystick zone, and the player loses their positional reference.

Key Implementation Parameters

Fixed vs Floating Joystick. Fixed—center always at the same screen position. Floating—center appears where the player first touched. For shooters and action games, floating is preferable: it adapts to your grip. But it has its own issue—if the activation zone is too large, the joystick can appear on accidental UI touches.

In Unity, implement via RectTransform in Canvas with ScreenSpace - Overlay. The joystick center is backgroundRect.anchoredPosition, the knob is knobRect.anchoredPosition. Calculate direction:

Vector2 delta = touchPosition - joystickCenter;
float distance = delta.magnitude;
Vector2 direction = delta / Mathf.Max(distance, radius); // normalize considering radius
knobRect.anchoredPosition = direction * Mathf.Min(distance, radius);
inputDirection = direction; // [-1,1] per axis

Dead Zone. Without a dead zone, the character jerks from tiny finger movements. Usually 0.15–0.2 of the radius—depends on the game. Racing games have smaller dead zones, strategy games larger.

Responsive Feel

Smoothness—via Vector2.Lerp or Vector2.MoveTowards when updating knob position:

knobRect.anchoredPosition = Vector2.Lerp(
    knobRect.anchoredPosition,
    targetKnobPos,
    Time.deltaTime * followSpeed
);

followSpeed 15–25 gives inertia that feels "physical." Above 40, inertia disappears, the knob moves instantly—good for shooters, not for platformers.

On Godot 4 similarly: Control node with custom _draw() for background and knob, update via _input(event) on InputEventScreenDrag.

Multitouch

Movement joystick and aiming joystick—two independent objects. Each locks its touch's fingerId on TouchPhase.Began and only processes events with that fingerId. Without this, quickly lifting one finger and touching another zone can transfer control to the wrong joystick.

Integration: 2–3 days. Cost calculated individually.