- Home /
Question by
AndreiPrystupchyk · Dec 04, 2020 at 04:14 PM ·
accelerometerinput manager
Accelerometer input working in Unity Remote, not working in build.
When used old input system Accelerometer input working in Unity Remote, not working in build.. If i tried the new one I had another problem: https://www.reddit.com/r/Unity3D/comments/k5brif/new_input_master_issue/
private void Start()
{
controller = gameObject.AddComponent<CharacterController>();
Debug.Log(SystemInfo.deviceType);
}
void Update()
{
groundedPlayer = controller.isGrounded;
if (groundedPlayer && playerVelocity.y < 0)
{
playerVelocity.y = 0f;
}
if (SystemInfo.deviceType == DeviceType.Handheld && SystemInfo.supportsAccelerometer == true)
{
Vector3 move = new Vector3(Input.acceleration.x, 0f, 0f);
}
else
{
Vector3 move = new Vector3(Input.GetAxis("Horizontal"), 0f, 0f);
controller.Move(move * Time.deltaTime * playerSpeed);
}
// Changes the height position of the player..
if (Input.GetButtonDown("Jump") && groundedPlayer)
{
playerVelocity.y += Mathf.Sqrt(jumpHeight * -3.0f * gravityValue);
}
playerVelocity.y += gravityValue * Time.deltaTime;
controller.Move(playerVelocity * Time.deltaTime);
}
Comment