Unity C# Mobile Control Swipe Left Right
I made a 3d game with Unity and C#. I don't know how to make a object (player) control to left and right with swipe on mobile screen. That's my C# code: using UnityEngine; public class PlayerMovement : MonoBehaviour { public Rigidbody rb; public float forwardForce = 300f; public float sidewaysForce = 200f; // Update is called once per frame void FixedUpdate() { rb.AddForce(0, 0, forwardForce * Time.deltaTime); if (Input.GetAxis("Horizontal") > 0.1) { rb.AddForce(sidewaysForce * Time.deltaTime, 0, 0); } if (Input.GetAxis("Horizontal") < -0.1) { rb.AddForce(-sidewaysForce * Time.deltaTime, 0, 0)
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.