One way would be using a Parallel node and a Repeater like the image I’ve attached for you, but probably the best way, would be if you handle all this self-contained in a custom action task, which both checks for touch in it’s execute as well as in it’s update. If in it’s Execute there is no touch, it simply returns failure (with EndAction(false) ). Here is an example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
publicclassExample:ActionTask<NavMeshAgent>{
protectedoverridevoidOnExecute(){
if(Input.touches==0){
EndAction(false);
return;
}
agent.SetDestination(Input.GetTouch(0).position);
}
protectedoverridevoidOnUpdate(){
if(Input.touches>0){
agent.SetDestination(Input.GetTouch(0).position);
}
if(!agent.hasPath||agent.remainingDistance==0){
EndAction(true);
}
}
}
Let me know if this works for you.
Thanks
Join us on Discord: https://discord.gg/97q2Rjh
Attachments:
Parallel.png
Login
Register
By registering on this website you agree to our Privacy Policy.