Issue with Touch Input on Android Phone
I am having issues when building my test game for my android phone. I am trying to make a simple platformer with on-screen buttons. The buttons work in the unity simulator, but they do not work when on my phone. The buttons light up, but they do not trigger the action. If I keep tapping them, sometimes they will randomly work. I have checked my input system and noscript, and I can't not find a reason why it's not working. Any advice would be appreciated. I am including the Input system build, the player input component, and the player movement noscript.
https://preview.redd.it/4ljwhorkuvde1.png?width=928&format=png&auto=webp&s=3d8a00c52e837600a89605164ddb68fed6fa4779
[Star = Player](https://preview.redd.it/k8qlm59puvde1.png?width=458&format=png&auto=webp&s=f050860aeb263e319dce968aa6980c2fbc8e3306)
`using Unity.VisualScripting;`
`using UnityEngine;`
`using UnityEngine.InputSystem;`
`public class StarControls : MonoBehaviour`
`{`
`private Rigidbody2D star;`
`private PlayerInput playerInput;`
`private bool hasMoved = false;`
`[SerializeField] private float moveSpeed = 1f;`
`[SerializeField] private float acceleration = 1f;`
`[SerializeField] private float maxVelocity = 6f;`
`[SerializeField] private LevelTimer levelTimer; //Need to move this to the gama manager as a start game function`
`[SerializeField] private GameStateManagementScript gameManager;`
`private InputAction moveAction;`
`private InputAction jumpAction;`
`private InputAction pauseAction;`
`private Vector2 moveInput;`
`private bool jumpInput;`
`private float isPaused;`
`private bool canJump = false;`
`[SerializeField] private float jumpForce = 1f;`
`[SerializeField] private Transform groundCheck; // Empty GameObject placed at the player's feet`
`[SerializeField] private float groundCheckRadius = 0.05f; // Radius of the ground check`
`[SerializeField] private LayerMask groundLayer; // Layer mask for what is considered ground`
`private bool isGrounded = false;`
`private void Start()`
`{`
`star = GetComponent<Rigidbody2D>();`
`playerInput = GetComponent<PlayerInput>();`
`moveAction = playerInput.actions["Move"];`
`jumpAction = playerInput.actions["Jump"];`
`pauseAction = playerInput.actions["Pause"];`
[`//pauseAction.performed`](//pauseAction.performed) `+= OnPausePressed;`
`canJump = true;`
`}`
`private void Update()`
`{`
`if (moveAction.IsPressed())`
`{`
`Move();`
`}`
`Move();`
`if (jumpAction.IsPressed())`
`{`
`Jump();`
`}`
`/*isGrounded = Physics2D.OverlapCircle(groundCheck.position, groundCheckRadius, groundLayer);`
`if (isGrounded)`
`{`
`onLand();`
`}`
`if (moveInput.y > 0 && canJump && Mathf.Abs(star.linearVelocityY) < maxVelocity)`
`{`
`star.AddForce(Vector2.up * jumpForce, ForceMode2D.Impulse);`
`canJump = false;`
`}`
`else if (moveInput.x > 0 && star.linearVelocityX < maxVelocity)`
`{`
`star.AddForce(new Vector2(moveInput.x * moveSpeed,0), ForceMode2D.Impulse);`
`}`
`else if (moveInput.x < 0 && star.linearVelocityX > (maxVelocity * -1))`
`{`
`star.AddForce(new Vector2(moveInput.x * moveSpeed, 0), ForceMode2D.Impulse);`
`}`
`if (!hasMoved && moveInput != Vector2.zero)`
`{`
`hasMoved = true;`
`levelTimer.StartTimer();`
`}*/`
`}`
`private void onLand()`
`{`
`canJump = true;`
`if (star.linearVelocity.x == 0)`
`{`
`return;`
`}`
`float decelerationDirection = -Mathf.Sign(star.linearVelocity.x);`
`star.AddForce(new Vector2(decelerationDirection * acceleration, 0), ForceMode2D.Impulse);`
`if (Mathf.Abs(star.linearVelocityX) < 0.5)`
`{`
`star.linearVelocityX = 0;`
`}`
`}`
`void OnDrawGizmos()`
`{`
`// Visualize the ground check in the editor`
`if (groundCheck != null)`
`{`
`Gizmos.color =` [`Color.red`](http://Color.red)`;`
`Gizmos.DrawWireSphere(groundCheck.position, groundCheckRadius);`
`}`
`}`
`/*private void OnPausePressed(InputAction.CallbackContext context)`
`{`
`gameManager.TogglePauseGame();`
`}`
`private void OnDestroy()`
`{`
`// Unsubscribe to avoid memory leaks`
`pauseAction.performed -=
I am having issues when building my test game for my android phone. I am trying to make a simple platformer with on-screen buttons. The buttons work in the unity simulator, but they do not work when on my phone. The buttons light up, but they do not trigger the action. If I keep tapping them, sometimes they will randomly work. I have checked my input system and noscript, and I can't not find a reason why it's not working. Any advice would be appreciated. I am including the Input system build, the player input component, and the player movement noscript.
https://preview.redd.it/4ljwhorkuvde1.png?width=928&format=png&auto=webp&s=3d8a00c52e837600a89605164ddb68fed6fa4779
[Star = Player](https://preview.redd.it/k8qlm59puvde1.png?width=458&format=png&auto=webp&s=f050860aeb263e319dce968aa6980c2fbc8e3306)
`using Unity.VisualScripting;`
`using UnityEngine;`
`using UnityEngine.InputSystem;`
`public class StarControls : MonoBehaviour`
`{`
`private Rigidbody2D star;`
`private PlayerInput playerInput;`
`private bool hasMoved = false;`
`[SerializeField] private float moveSpeed = 1f;`
`[SerializeField] private float acceleration = 1f;`
`[SerializeField] private float maxVelocity = 6f;`
`[SerializeField] private LevelTimer levelTimer; //Need to move this to the gama manager as a start game function`
`[SerializeField] private GameStateManagementScript gameManager;`
`private InputAction moveAction;`
`private InputAction jumpAction;`
`private InputAction pauseAction;`
`private Vector2 moveInput;`
`private bool jumpInput;`
`private float isPaused;`
`private bool canJump = false;`
`[SerializeField] private float jumpForce = 1f;`
`[SerializeField] private Transform groundCheck; // Empty GameObject placed at the player's feet`
`[SerializeField] private float groundCheckRadius = 0.05f; // Radius of the ground check`
`[SerializeField] private LayerMask groundLayer; // Layer mask for what is considered ground`
`private bool isGrounded = false;`
`private void Start()`
`{`
`star = GetComponent<Rigidbody2D>();`
`playerInput = GetComponent<PlayerInput>();`
`moveAction = playerInput.actions["Move"];`
`jumpAction = playerInput.actions["Jump"];`
`pauseAction = playerInput.actions["Pause"];`
[`//pauseAction.performed`](//pauseAction.performed) `+= OnPausePressed;`
`canJump = true;`
`}`
`private void Update()`
`{`
`if (moveAction.IsPressed())`
`{`
`Move();`
`}`
`Move();`
`if (jumpAction.IsPressed())`
`{`
`Jump();`
`}`
`/*isGrounded = Physics2D.OverlapCircle(groundCheck.position, groundCheckRadius, groundLayer);`
`if (isGrounded)`
`{`
`onLand();`
`}`
`if (moveInput.y > 0 && canJump && Mathf.Abs(star.linearVelocityY) < maxVelocity)`
`{`
`star.AddForce(Vector2.up * jumpForce, ForceMode2D.Impulse);`
`canJump = false;`
`}`
`else if (moveInput.x > 0 && star.linearVelocityX < maxVelocity)`
`{`
`star.AddForce(new Vector2(moveInput.x * moveSpeed,0), ForceMode2D.Impulse);`
`}`
`else if (moveInput.x < 0 && star.linearVelocityX > (maxVelocity * -1))`
`{`
`star.AddForce(new Vector2(moveInput.x * moveSpeed, 0), ForceMode2D.Impulse);`
`}`
`if (!hasMoved && moveInput != Vector2.zero)`
`{`
`hasMoved = true;`
`levelTimer.StartTimer();`
`}*/`
`}`
`private void onLand()`
`{`
`canJump = true;`
`if (star.linearVelocity.x == 0)`
`{`
`return;`
`}`
`float decelerationDirection = -Mathf.Sign(star.linearVelocity.x);`
`star.AddForce(new Vector2(decelerationDirection * acceleration, 0), ForceMode2D.Impulse);`
`if (Mathf.Abs(star.linearVelocityX) < 0.5)`
`{`
`star.linearVelocityX = 0;`
`}`
`}`
`void OnDrawGizmos()`
`{`
`// Visualize the ground check in the editor`
`if (groundCheck != null)`
`{`
`Gizmos.color =` [`Color.red`](http://Color.red)`;`
`Gizmos.DrawWireSphere(groundCheck.position, groundCheckRadius);`
`}`
`}`
`/*private void OnPausePressed(InputAction.CallbackContext context)`
`{`
`gameManager.TogglePauseGame();`
`}`
`private void OnDestroy()`
`{`
`// Unsubscribe to avoid memory leaks`
`pauseAction.performed -=
OnPausePressed;`
`}*/`
`public void OnMove(InputValue context)`
`{`
`Debug.Log("OnMove");`
`moveInput = context.Get<Vector2>();`
`}`
`private void Move()`
`{`
`Debug.Log("Move" + moveInput);`
`if (moveInput.x > 0 && star.linearVelocityX < maxVelocity)`
`{`
`star.AddForce(new Vector2(moveInput.x * moveSpeed, 0), ForceMode2D.Impulse);`
`}`
`else if (moveInput.x < 0 && star.linearVelocityX > (maxVelocity * -1))`
`{`
`star.AddForce(new Vector2(moveInput.x * moveSpeed, 0), ForceMode2D.Impulse);`
`}`
`if (!hasMoved && moveInput != Vector2.zero)`
`{`
`hasMoved = true;`
`levelTimer.StartTimer();`
`}`
`}`
`/*public void OnJump()`
`{`
`}*/`
`private void Jump()`
`{`
`Debug.Log("Jump");`
`isGrounded = Physics2D.OverlapCircle(groundCheck.position, groundCheckRadius, groundLayer);`
`if (isGrounded)`
`{`
`onLand();`
`}`
`if (canJump && Mathf.Abs(star.linearVelocityY) < maxVelocity)`
`{`
`star.AddForce(Vector2.up * jumpForce, ForceMode2D.Impulse);`
`canJump = false;`
`}`
`}`
`public void OnPause()`
`{`
`gameManager.TogglePauseGame();`
`}`
`}`
https://redd.it/1i4qyhd
@r_Unity3D
`}*/`
`public void OnMove(InputValue context)`
`{`
`Debug.Log("OnMove");`
`moveInput = context.Get<Vector2>();`
`}`
`private void Move()`
`{`
`Debug.Log("Move" + moveInput);`
`if (moveInput.x > 0 && star.linearVelocityX < maxVelocity)`
`{`
`star.AddForce(new Vector2(moveInput.x * moveSpeed, 0), ForceMode2D.Impulse);`
`}`
`else if (moveInput.x < 0 && star.linearVelocityX > (maxVelocity * -1))`
`{`
`star.AddForce(new Vector2(moveInput.x * moveSpeed, 0), ForceMode2D.Impulse);`
`}`
`if (!hasMoved && moveInput != Vector2.zero)`
`{`
`hasMoved = true;`
`levelTimer.StartTimer();`
`}`
`}`
`/*public void OnJump()`
`{`
`}*/`
`private void Jump()`
`{`
`Debug.Log("Jump");`
`isGrounded = Physics2D.OverlapCircle(groundCheck.position, groundCheckRadius, groundLayer);`
`if (isGrounded)`
`{`
`onLand();`
`}`
`if (canJump && Mathf.Abs(star.linearVelocityY) < maxVelocity)`
`{`
`star.AddForce(Vector2.up * jumpForce, ForceMode2D.Impulse);`
`canJump = false;`
`}`
`}`
`public void OnPause()`
`{`
`gameManager.TogglePauseGame();`
`}`
`}`
https://redd.it/1i4qyhd
@r_Unity3D
Reddit
From the Unity2D community on Reddit
Explore this post and more from the Unity2D community
Help with 2d and 3d Lights in already existing project!
Dear r/Unity3D,
I have a question regarding a project I’m currently developing.
In my game, a narrator showcases games he created over the years. Some of these games are in 2D, while others are in 3D. I’ve encountered an issue where I can’t get 2D and 3D lights to work together properly.
For my 3D scenes, I need to update the scene, I’ve been using the Built-In to URP option in the Render Pipeline Converter. While this makes the 3D scenes work as intended, it causes my 2D scenes to break because the 2D lights are removed in the process.
I need to do this Built-In to URP step for the 3D to look like intended but i also require 2D lights for the other scenes. Is there a way to fix this and have both types of lights coexist within the same project? And the thing is that these games are already created with 2d lights so switching would be painful. Is there any other way to do it?
(Im using Unity 2022.3.9f1)
Thank you in advance for your help!
https://redd.it/1i4y737
@r_Unity3D
Dear r/Unity3D,
I have a question regarding a project I’m currently developing.
In my game, a narrator showcases games he created over the years. Some of these games are in 2D, while others are in 3D. I’ve encountered an issue where I can’t get 2D and 3D lights to work together properly.
For my 3D scenes, I need to update the scene, I’ve been using the Built-In to URP option in the Render Pipeline Converter. While this makes the 3D scenes work as intended, it causes my 2D scenes to break because the 2D lights are removed in the process.
I need to do this Built-In to URP step for the 3D to look like intended but i also require 2D lights for the other scenes. Is there a way to fix this and have both types of lights coexist within the same project? And the thing is that these games are already created with 2d lights so switching would be painful. Is there any other way to do it?
(Im using Unity 2022.3.9f1)
Thank you in advance for your help!
https://redd.it/1i4y737
@r_Unity3D
Reddit
Unity 3D - News, Help, Resources, and Showcase
A subreddit for News, Help, Resources, and Conversation regarding Unity, the game engine.
Do NOT use your phone to take screenshots. Video and photos of computer screens taken by phones are NOT allowed. All screenshots must be grabbed from the computer…
Do NOT use your phone to take screenshots. Video and photos of computer screens taken by phones are NOT allowed. All screenshots must be grabbed from the computer…
Updating Visual Studio to 17.x+ then closing and reopening all my noscripts fixed Domain Reloading and ApplicationStart/End Times (40s->2s)
I need to share the accidental magic that hit me. My giant project had 15-20s domain reloads on code changes, 40s to open and 20s to close playmode. I updated my Visual Studio to the newest version (17.12.3). This brought little change in load times. A day later I was messing with the newish VS tabs features and clicked close all tabs on accident. Closed Unity. Since then my loading times have dropped to near nothing. I still have Domain and Scene Reloading enabled, nothing else is different but it loads near instantly. Anyone with waiting headaches try it and please tell me if it affects your load times.
https://redd.it/1i4x3dr
@r_Unity3D
I need to share the accidental magic that hit me. My giant project had 15-20s domain reloads on code changes, 40s to open and 20s to close playmode. I updated my Visual Studio to the newest version (17.12.3). This brought little change in load times. A day later I was messing with the newish VS tabs features and clicked close all tabs on accident. Closed Unity. Since then my loading times have dropped to near nothing. I still have Domain and Scene Reloading enabled, nothing else is different but it loads near instantly. Anyone with waiting headaches try it and please tell me if it affects your load times.
https://redd.it/1i4x3dr
@r_Unity3D
Reddit
From the Unity3D community on Reddit
Explore this post and more from the Unity3D community
I’m currently working on sets for my indie video game, what do you think?
https://redd.it/1i534h2
@r_Unity3D
https://redd.it/1i534h2
@r_Unity3D
Reddit
From the Unity2D community on Reddit: I’m currently working on sets for my indie video game, what do you think?
Explore this post and more from the Unity2D community
This media is not supported in your browser
VIEW IN TELEGRAM
• Once I saw Johnny Silverhand's glitch effect, I wanted to reconstruct it—and I think I made it even better ¯\(ツ)/¯
https://redd.it/1i53tkm
@r_Unity3D
https://redd.it/1i53tkm
@r_Unity3D
Finally Announcing Death Kid! An arcade-inspired arena brawler with meta-progression. Nearly 8 years in the making during my spare time.
https://www.youtube.com/watch?v=u7Y6g4CJD_E
https://redd.it/1i56qa7
@r_Unity3D
https://www.youtube.com/watch?v=u7Y6g4CJD_E
https://redd.it/1i56qa7
@r_Unity3D
YouTube
Death Kid - Reveal Trailer
WISHLIST ON STEAM!
https://store.steampowered.com/app/3456970/Death_Kid/
Death Kid is a fast-paced arena brawler where you must protect three souls trapped between life and death. Your goal is to give them enough time to open a passage leading deeper into…
https://store.steampowered.com/app/3456970/Death_Kid/
Death Kid is a fast-paced arena brawler where you must protect three souls trapped between life and death. Your goal is to give them enough time to open a passage leading deeper into…
This media is not supported in your browser
VIEW IN TELEGRAM
Currently working on a game that combines Pinball and TowerDefense ✨
https://redd.it/1i559vv
@r_Unity3D
https://redd.it/1i559vv
@r_Unity3D
This media is not supported in your browser
VIEW IN TELEGRAM
My first time starting a project in HDRP, and the lighting and volumetric fog is blowing me away!
https://redd.it/1i56h1t
@r_Unity3D
https://redd.it/1i56h1t
@r_Unity3D