Question by
Aashish0 · May 26, 2020 at 04:17 PM ·
movementinputmobileplayer movementmobile devices
the player input is jittery seems like glitching
I am using this script mobile input, player movement and rotation but it seems very jittery and lagging on the phone. is there any other way to do the same. Please help i am new to unity and c#
if (Input.touchCount > 0)
{
// for forward movement
if (canmove == true)
{ rb.AddForce(0, 0, ForwardForce * Time.deltaTime); }
touch = Input.GetTouch(0);
if (touch.phase == TouchPhase.Moved)
{
transform.position = new Vector3(
transform.position.x + touch.deltaPosition.x * speedModifier,
transform.position.y, transform.position.z);
rotateY = Quaternion.Euler(
0f, 0f, -touch.deltaPosition.x * rotatespeedModifier);
transform.rotation = rotateY * transform.rotation;
}
}
else if(Input.touchCount < 0)
{
canmove = false;
}
Comment
Your answer
Follow this Question
Related Questions
Trouble with cross platform input in mobile multiplayer 1 Answer
New Input System - On-screen stick only recieves initial input 0 Answers
How can i use a joystick for mobile game in this short movement script? 0 Answers
Im trying to make a player move 360 degree gyroscopic movement on my phone 0 Answers
Player only moves when the key is pressed, not when it's held. 0 Answers