- Home /
 
 
               Question by 
               AlexTselikas · Oct 20, 2013 at 05:09 PM · 
                playercontrol  
              
 
              Use GUITexture to control Player
Hi, i want to use a GUITexture to control my Player.I made a script to control my player and now i want to control my player. How can i do that? I mean i can make the GUITexture to do sth but how i can make it control the Player
               Comment
              
 
               
              Answer by AlexTselikas · Oct 21, 2013 at 05:50 PM
I found the answer.Although i have one problem.i can't make my player move smoothly on the plane.It just goes flying by :
 var rotationSpeed = 100;
 var jumpHeight = 8;
 
 var left : GUITexture;
 var right : GUITexture;
 var up : GUITexture;
 
 private var isFalling = false; 
 
 function Awake() {
 left  = GameObject.Find("left").guiTexture;
 right  = GameObject.Find("right").guiTexture;
 up = GameObject.Find("up").guiTexture;
 }
 
 function Update () {
     for (var touch : Touch in Input.touches){
     if (touch.phase == TouchPhase.Stationary && left.HitTest (touch.position)){
     rigidbody.velocity = transform.right * -10;
     }
     }
     for (var touch : Touch in Input.touches){
     if (touch.phase == TouchPhase.Stationary && right.HitTest (touch.position)){
     rigidbody.velocity = transform.right * 10;
     }
     
     }
     for (var touch : Touch in Input.touches){
     if (touch.phase == TouchPhase.Stationary && up.HitTest (touch.position) && isFalling == false){
     rigidbody.velocity.y = jumpHeight;
     }
     }
     
     isFalling = true;
 }
 
 function OnCollisionStay ()
 {
     isFalling = false;
 }
 
              Your answer