Thanks in advance
i’m doing for android a game,in pc we have
input.getbuttondown right?
android we have touch.began,but on android how can i verify if the user dropped the finger of touchscreen?
an example
when user touch happend something and the character collid with terrain its just an example
when collid on terrain to execute the action again you need touch again,how can i do it?
touch.began is basically a boolean. Try something like !touchbegan
An example,this code is in the Character Script,it verify if character is grounded,right?
if (Physics.Raycast (transform.position,-Vector3.up, 0.8));
ground=true;
Below is jump code!
if (cap.transform.name == “jump” && ground==true){ //if the game object below change your name by jump
jumpspeed= 8* Time.deltaTime;
tcont=tcont*Time.deltaTime;
if (tcont<=maximo && tocou==true)
transform.Translate (0, jumpspeed, 0);
if(tcont>maximo)
if (cap.transform.name == “Cube”)
tocou=false;
tcont=0;
jumpspeed=0;
And then i have another script that is for button
var texto:String;
var cap:GameObject;
function Start () {
texto= “vazio”;
}
function Update () {
for(var i:int =0; i < Input.touches.Length; i++){ // quantos toques voce tem ??
var touch:Touch=Input.touches*; //o toque*
var ray = Camera.main.ScreenPointToRay (Input.GetTouch(i).position);
var hit:RaycastHit =new RaycastHit ();
if(Physics.Raycast(ray,hit,1000)){
if(hit.collider.gameObject == cap){
if( TouchPhase.Began){ //if touch begin
texto =“jump”;
cap.transform.name = “jump”; //this game object
break;
if (TouchPhase.Ended) {// se o toque começar
texto = “Tirou o dedo no objeto”;
cap.transform.name = “Cube”;
break;
}
}
How can i do it?I tried but i think that is impossible
You can check for TouchPhase.Canceled too: Unity - Scripting API: TouchPhase.Canceled