How can i use a joystick for mobile game in this short movement script?
Hello, I am trying to develop a 2D game for mobile use.
Q: Can anyone perhaps assist me to make this line of code use a mobile joystick.
"The reason being is that it gives me a very cool movement on the character "
its works on pc controls but i cannot seem to make it work on the joystick.
I am using Unity 2019.3.13 , Visual studios , C#, windows 10 Anyway here goes-
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class PlayerControler : MonoBehaviour { protected Joystick joystick;
void Start() { joystick = FindObjectOfType();
void Update()
{
JoyStickControls();
}
public void JoyStickControls()
{
This is the line I'm not sure where or how to ad the joystick bit or if it even would work with this lines of code:
//???????????????????????????????????????????????????????????????????????????????????????????????????????? Vector2 moveInput = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical")); moveVelocity = moveInput.normalized * speed;
//????????????????????????????????????????????????????????????????????????????????????????????????????????
I have tried this:
// Vector2 moveInput = new Vector2(Joystick.GetAxisRaw("Horizontal"),
Joystick.GetAxisRaw("Vertical"));
//moveVelocity = moveInput.normalized * speed;
Hope someone can help or at least let me know if it is possible to do so, don't want to waste more time trying to make it work if its not possible, thank you in advance!
Your answer
![](https://koobas.hobune.stream/wayback/20220613004118im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
the player input is jittery seems like glitching 0 Answers
WASD Joystick Movement Android 0 Answers
Moving forward seems to be specific to the original direction of the object being controlled 0 Answers
How can I implement limits to my player so it doesn't come out of the main camera? 0 Answers
help with player movement 0 Answers