Wir haben die Lösung für dieses Dilemma, oder zumindest wünschen wir uns. Wenn Sie Bedenken haben, teilen Sie es in einem Kommentar mit, wir helfen Ihnen gerne weiter
Beispiel: unity mobile controls
usingSystem.Collections;usingSystem.Collections.Generic;usingUnityEngine;publicclassMovement:MonoBehaviour{//variablespublicfloat moveSpeed =300;publicGameObject character;privateRigidbody2D characterBody;privatefloat ScreenWidth;// Use this for initializationvoid Start (){
ScreenWidth = Screen.width;
characterBody = character.GetComponent<Rigidbody2D>();}// Update is called once per framevoid Update (){int i =0;//loop over every touch foundwhile(i < Input.touchCount){if(Input.GetTouch (i).position.x > ScreenWidth /2){//move right
RunCharacter (1.0f);}if(Input.GetTouch (i).position.x < ScreenWidth /2){//move left
RunCharacter (-1.0f);}++i;}}voidFixedUpdate(){#ifUNITY_EDITORRunCharacter(Input.GetAxis("Horizontal"));#endif}privatevoidRunCharacter(float horizontalInput){//move player
characterBody.AddForce(newVector2(horizontalInput * moveSpeed * Time.deltaTime,0));}}