playMaker

Author Topic: Character Moves to finger tap point for iOS ? [SOLVED]  (Read 9371 times)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14059
  • Official Playmaker Support
    • View Profile
Re: Character Moves to finger tap point ?
« Reply #15 on: November 15, 2012, 05:10:48 AM »
Hi,

 just to make sure of one thing.

 Do you own a unity 3 pro version? if not have you tried Unity 4 and mecanim? I mean this is just pur mind blowing stuff on that front, so maybe it would be wise to start using Unity 4 and mecanim. I am currently studying how playmaker can work with mecanim. For example there is a test scene where you shoot at a bear or another where bears are following you, the amount of code to have this working is really low and totally doable in Unity with few custom actions that I am brainstorming now.

Bye,

 Jean

mickman

  • Junior Playmaker
  • **
  • Posts: 60
    • View Profile
Re: Character Moves to finger tap point ?
« Reply #16 on: November 16, 2012, 12:20:24 PM »
Hi Jean,

yes I have Unity4 Pro iOS.   I upgraded last night.  Mechanim does look pretty darn cool... just need some decent MoCap files to run with it.... but having said that, a couple of weeks back the London Unity Users Group "LUUG" demonstrated Mechanim.  Will Goldstone gave a great rundown of Mechanim. note:Will wrote the Unity3.0 reference book "Unity 3.x Game Dev. Essentials " by Packt.

 I'm developing for iPhone & iPad so I hope Mechanim will optimise things a little more.  

Really excited to try out the shadows & Shuriken particle system too... so much to take in with the latest release.

Back to my Dilemma...  I'm really just trying to get a character to navigate to finger tap positions.  I have the character moving about the scene but without walk/run cycles ( he simply floats around in idle ).
 I animated my character in Maya. I have him walking, jumping etc.. but in Unity I have him operating well but only with keyboard controls which is not cool for iPhone / iPad.

 Are you suggesting that it might be wiser to port the character into Mechanim & add the finger tap gestures using PlayMaker.. yes ?   If so... I'd really appreciate some help regarding getting a Mechanimised character to react to finger tap gestures using PlayMaker.

 note: I also have asset store "Finger Gestures" actions installed into PlayMaker.

 --MickMan    

 
« Last Edit: November 16, 2012, 12:45:42 PM by mickman »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14059
  • Official Playmaker Support
    • View Profile
Re: Character Moves to finger tap point ?
« Reply #17 on: November 16, 2012, 01:30:47 PM »
Hi,

 I see, I'll come up with something then.

bye,

 Jean

mickman

  • Junior Playmaker
  • **
  • Posts: 60
    • View Profile
setting Character up for mecanim
« Reply #18 on: November 17, 2012, 02:47:08 AM »
I have my character setup in mecanim.
I need to understand how I can integrate PlayMaker  i.e.. "get Touch "  to trigger the mecanim transition from idle to walk & a jump.

Edit -  OK I have the character walking in mecanim.  but just a single state.. so he simply walks, I have no control.   I do have a separate Blend tree setup in mecanim with idle/run / jump.   just need to understand how Playmaker can trigger finger gestures to trigger each mecanim transition.

this script might help...

but currently I'm having issues with the lines in Bold since they all refer to keyboard Input (not ios Touch)

I get the following error :
error CS1502: The best overloaded method match for `UnityEngine.Input.GetTouch(int)' has some invalid arguments



using UnityEngine;
using System;
using System.Collections;
[RequireComponent(typeof(Animator))]

public class BearCtrl : MonoBehaviour {
   protected Animator animator;
   public float DirectionDampTime = 0.25f;
   

   void Start ()
   {
   animator.GetComponent<animator>();
   }
   
   
   void Update ()
   {
   animator.SetBool ("Jump",Input.GetTouch ("Touched") );
      float h = Input.GetAxis ("Horizontal");
      float v = Input.GetAxis ("Vertical");

      
      animator.SetFloat("Speed", h*h+v*v);
      animator.SetFloat("Direction", h, DirectionDampTime, Time.deltaTime);
   }
}


NOTES:    Variables created in mecanim  

            
  • Jump  = a Boolean Param I created in mecanim.
  •  Direction = float
  •   Speed = float

Touched = an event I created in PlayMaker.



          
            


 
« Last Edit: November 17, 2012, 06:40:01 PM by mickman »

mickman

  • Junior Playmaker
  • **
  • Posts: 60
    • View Profile
Re: Character Moves to finger tap point ?
« Reply #19 on: November 18, 2012, 12:51:02 PM »
So the question remains,  how to get iOS finger taps to move a mechanim character ? 

Mick

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14059
  • Official Playmaker Support
    • View Profile
Re: Character Moves to finger tap point ?
« Reply #20 on: November 18, 2012, 10:14:37 PM »
Hi,

 Touch input management is unfortunately not that straight forward... It's a lot more involving. You need to catch all touch events, filter them by ID's and status ( when they begin, end, are cancelled) and then record the position of the right touch and compute the animation to have the character translating.  So not really something doable without a proper experience in scripting and touch management.

I have planned to create a first bridge to Animator this week, and I will make the first example using touch and tap  to move the player so that you can have a clear example.


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14059
  • Official Playmaker Support
    • View Profile
Re: Character Moves to finger tap point ?
« Reply #21 on: November 22, 2012, 03:10:26 AM »
Hi,

 ok, I have made a Mecanim port of the "follow" behavior they show in the mecanim samples, and this is what would work for your case basically.

 As you touch the ground, you position a dummy gameObject that this follow action follows, and your avatar will go there magically :)

http://hutonggames.com/playmakerforum/index.php?topic=2603.0

bye,

 Jean

mickman

  • Junior Playmaker
  • **
  • Posts: 60
    • View Profile
[SOLVED]
« Reply #22 on: November 22, 2012, 09:44:20 AM »
 ;D  Happy Times !!  

I'll start playing with it immediately & leave some feedback as I get used to Mecanim.

 This will really allow me to move into new areas of iOS gaming & in particular AR.

  Thanks Jean.. Thanks so incredibly much, I realise this was not your normal quick fix & as such I really appreciate the time you put into bringing this ability to PlayMaker.

Awesome !  :D

 


 

 
« Last Edit: November 22, 2012, 09:46:03 AM by mickman »