Question by
downfieldtoast · Mar 26 at 08:42 AM ·
charactercontrollersupport
Unity Remote 5 not working with UI joystick or buttons
I am using the Input System package and I can move the joystick with my mouse but not using my phone. Not sure if this has relevance but I can also click buttons using my mouse but not touchscreen.
Heres my movement code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class InputPKG : MonoBehaviour
{
[SerializeField] private Rigidbody rb;
[SerializeField] private float speed = 5;
[SerializeField] private float turnSpeed = 360;
private Vector3 input;
[SerializeField] private Transform model;
private void Update()
{
GatherInput();
Look();
}
private void FixedUpdate()
{
Move();
}
public void GatherInput()
{
Vector2 stickValue = Gamepad.current.leftStick.ReadValue();
input = new Vector3(stickValue.x, 0, stickValue.y);
}
private void Look()
{
if (input == Vector3.zero) return;
Quaternion rot = Quaternion.LookRotation(input.ToIso(), Vector3.up);
model.rotation = Quaternion.RotateTowards(model.rotation, rot, turnSpeed * Time.deltaTime);
}
private void Move()
{
rb.MovePosition(transform.position + input.ToIso() * input.normalized.magnitude * speed * Time.deltaTime);
}
}
Comment
Your answer
Follow this Question
Related Questions
How to Check if Mecanim animation has finished? 0 Answers
Help! Collision will not work, but all others will 0 Answers
Implementing sprint in Brackeys FPS Tutorial 2 Answers
How to properly interact between UnityEngine.CharacterController and rigidbody? 0 Answers
How can I modify this to allow jumping with space? 0 Answers