Quantcast
Channel: Questions in topic: "left"
Viewing all articles
Browse latest Browse all 135

Move player to left and right ( android Touche )

$
0
0
this script its for windows keyboard i want switch to android touche using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerController: MonoBehaviour { public float horizontalInput ; public float speed = 10.0f; public GameObject character; public GameObject projectilePrefab; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { if(transform.position.x < -20) { transform.position = new Vector3(-20, transform.position.y , transform .position.z ); } else if (transform.position.x > 20) { transform.position = new Vector3(20.0f, transform.position.y, transform.position.z); } horizontalInput = Input.GetAxis("Horizontal"); transform.Translate(Vector3.right * horizontalInput * Time.deltaTime * speed); if (Input.GetKeyDown(KeyCode.Space)) { Instantiate(projectilePrefab, transform.position, projectilePrefab.transform.rotation); } } }

Viewing all articles
Browse latest Browse all 135

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>