- Home /
Question by
deadfire56 · Jun 30, 2011 at 01:57 AM ·
iphonetouchmultitouch
Multiple touch iPhone Buttons
Hey unity, I've got four GUITexture buttons: two for left and right, two for attack. They all work perfectly on. When one of the directional buttons is pressed and then one of the attack buttons are pressed I would like it to switch over to the attack animation even if the left and right are being held down. Thanks for any help!
Directional Code
var theMainCharacter: GameObject;
private var gui : GUITexture;
function Start(){
gui = GetComponent( GUITexture );
}
function Update() {
if(Input.touchCount > 0){
var touch: Touch = Input.GetTouch(0);
if(touch.phase == TouchPhase.Stationary && gui.HitTest(touch.position)){
theMainCharacter.transform.eulerAngles = Vector3(0, 90, 0);
theMainCharacter.transform.position.x +=.1;
theMainCharacter.animation.CrossFade("walk001");
}
if(touch.phase == TouchPhase.Ended && gui.HitTest(touch.position)){
theMainCharacter.animation.CrossFade("idle001");
}
}
}
Attack Code
var theMainCharacter: GameObject;
private var gui : GUITexture;
function Start(){
gui = GetComponent(GUITexture);
}
function Update() {
if(Input.touchCount > 0){
var touch: Touch = Input.GetTouch(0);
if(touch.phase == TouchPhase.Stationary && gui.HitTest(touch.position)){
theMainCharacter.animation.CrossFade("kick001");
}
if(touch.phase == TouchPhase.Ended && gui.HitTest(touch.position)){
theMainCharacter.animation.CrossFade("idle001");
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Input.GetTouch SOMETIMES not registering on iOS 0 Answers
iPhone multitouch 0 Answers
input.touch effect ever object script is attached to 1 Answer
iPhone Multitouch Problem 1 Answer