Playmaker Forum

Playmaker Help & Tips => Playmaker Help => Topic started by: mickman on November 04, 2012, 02:44:33 PM

Title: Character Moves to finger tap point for iOS ? [SOLVED]
Post by: mickman on November 04, 2012, 02:44:33 PM
Hi,

I'm trying to get a 3rd person character controller to follow wherever I tap on screen.

So before I venture onwards, I'm wondering if this has already been accomplished. (finding it hard to find anything on the forum)  

Character Actions:
walk- one finger tap
run -  two finger tap

controller should turn and point towards the tapped point.  

 So maybe this has already been created by other PlayMaker users... if so I'd appreciate a link.


  

 
Title: Re: Character Moves to finger tap point ?
Post by: jeanfabre on November 04, 2012, 10:35:24 PM
hi,

 Your first stop is the penelope sample from Unity, I can recall they have something like that as one variant for controlling the character.

http://unity3d.com/support/resources/tutorials/penelope (http://unity3d.com/support/resources/tutorials/penelope)


bye,

 Jean
Title: Re: Character Moves to finger tap point ?
Post by: mickman on November 05, 2012, 03:02:02 AM
How about I utilise these actions.

Get Touch
Screen to World
iTween Look to


 mmm...  itween.  ;)  

 I looked over a few PlayMaker Vids. they help a lot. itween allows for ease in-out, making more professional motions.
Title: Re: Character Moves to finger tap point ?
Post by: jeanfabre on November 05, 2012, 04:34:12 AM
Hi,

 yep, that can do too, if you haven't yet any controllers for your character, iTween would be quite a good start.

Also, check hotween. I have created a set of actions for this. It may very well perform better if you are planning on mobile development.
http://hutonggames.com/playmakerforum/index.php?topic=2299.0 (http://hutonggames.com/playmakerforum/index.php?topic=2299.0)


bye,

 Jean
Title: Re: Character Moves to finger tap point ?
Post by: mickman on November 06, 2012, 05:19:08 PM
Hi Jean,

Here is a quick video I created showing my problem.  Basically the character moves to wherever I tap on the ground plane but the character's run animation is not playing.  ( note: the video does zoom in close to help with better viewing )

Title: Re: Character Moves to finger tap point ?
Post by: mickman on November 07, 2012, 01:18:56 AM
I'm going to load up Hotween later in the week to give it a run through. So to achieve similar results, using a tap gesture to move the character, would I simply add a Hotween onto the character and then adjust settings using the Hotween visual editor ?



Title: Re: Character Moves to finger tap point ?
Post by: jeanfabre on November 07, 2012, 02:12:57 AM
Hi,

there is two different aspect here, if the animation is not triggering, then it's likely because you don't have the right controller, and since you are indeed moving the player programatically as opposed to listening to user's input, it's likely that the animation will not trigger indeed without modifying your controller.

[EDIT]
ok I get it, I think you are in conflict with the player animation controller that could be there.

What you need to do try and trigger the run animation without even walking anywhere, just by pressing a button or something. And take it from there, automatic player movement and animation triggering problems are not related really.

Hotween is not visual. you will have to use playmaker actions to define the hotween action.

 you might actually want to avoid all this all together by simply having a simpler set up where your player is following a target using maybe "smooth follow" or "move towards"

bye,

 Jean

bye,

 Jean
Title: Re: Character Moves to finger tap point ?
Post by: mickman on November 07, 2012, 03:47:40 AM
Hi,

Thanks for the reply Jean,

When you say   " if the animation is not triggering, then it's likely because you don't have the right controller, and since you are indeed moving the player programatically as opposed to listening to user's input, "

but the player is being moved by user input  ( a tap gesture ) yes ?


I simply need to know, how to apply the "play animation" action when the character controller moves in world space.

Would be great to have an action that fires a play animation when a controller moves

 eg.  single tap =           play walk ( = speed 1 )
                                   > speed1 - play run
                                    else -  play idle
                                    else if double tap -  play jump

 I tried to have the animation play on the joypad setup but was similar issues so I decided to try another approach ( hence the tap screen ) 
  I guess I now have an understanding of setting up both controller settings.. that's a bonus ;)     I could even incorporate both styles into one game providing the player with several controller choices. 



Title: Re: Character Moves to finger tap point ?
Post by: jeanfabre on November 07, 2012, 03:54:53 AM
Hi,

 do you have a controller of some sort on your player? I think it's related

playing an animation using playmaker action works, so if it doesn't trigger, it's likely because there is a clash somewhere. For example a player controller that keep playing the idle animation for example.

bye,

 Jean
Title: Re: Character Moves to finger tap point ?
Post by: mickman on November 07, 2012, 04:01:14 AM
Hi Jean,  

yes the idle animation does keep playing ...    it's the standard third person controller setup (the Construction worker )

Simply moving a capsule about is relatively straight forward... but getting an animation to fire as the capsule moves is driving me nuts   ???

 Jean, is there any chance you could add a  play animation to one of the iOS example files.  That would be really helpful.  This way I can better comprehend transitioning from one state to the next where a play animation action is called.



  
Title: Re: Character Moves to finger tap point ?
Post by: jeanfabre on November 08, 2012, 03:15:20 AM
Hi,

 Simply delete that controller indeed, since you don't need it and the animations you fire will not be shunted.

which IOS example files you mean? if you point me to the right scene, I'll happily have a look.

 I have made some samples available with quite advanced animation control done in playmaker, you might wanbt to take a look as well:
http://hutonggames.com/playmakerforum/index.php?topic=2267.0 (http://hutonggames.com/playmakerforum/index.php?topic=2267.0)

bye,

 Jean
Title: Re: Character Moves to finger tap point ?
Post by: mickman on November 08, 2012, 08:30:17 AM
Hi,

 The example package =  ControllerSimpleMoveMobileJoystick.unitypackage

The primitive cylinder could be changed out for the Construction worker &
 add a play animation action to the controller.  (  An  Idle - walk - run animation would be neat since these already come installed with the construction worker's 3rd person controller )  

 note:This is iOS based so no keyboard controls.

That would help me so incredibly much to comprehend where I'm going wrong here.

 Mick
Title: Re: Character Moves to finger tap point ?
Post by: jeanfabre on November 08, 2012, 11:36:05 PM
Hi,

 ok, allow me few days to come up with this, if you don't hear me by mid next week, please bump this thread, thanks.


bye,

 Jean
Title: Re: Character Moves to finger tap point ?
Post by: mickman on November 14, 2012, 01:34:36 AM
Bump....    :)
Title: Re: Character Moves to finger tap point ?
Post by: jeanfabre on November 14, 2012, 02:53:26 AM
Hi,

 yep, I am on the case, I am currently mapping the anims, so it will take some more time.

bye,

 Jean
Title: Re: Character Moves to finger tap point ?
Post by: jeanfabre 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
Title: Re: Character Moves to finger tap point ?
Post by: mickman 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    

 
Title: Re: Character Moves to finger tap point ?
Post by: jeanfabre on November 16, 2012, 01:30:47 PM
Hi,

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

bye,

 Jean
Title: setting Character up for mecanim
Post by: mickman 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  

            
Touched = an event I created in PlayMaker.



          
            


 
Title: Re: Character Moves to finger tap point ?
Post by: mickman on November 18, 2012, 12:51:02 PM
So the question remains,  how to get iOS finger taps to move a mechanim character ? 

Mick
Title: Re: Character Moves to finger tap point ?
Post by: jeanfabre 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.

Title: Re: Character Moves to finger tap point ?
Post by: jeanfabre 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 (http://hutonggames.com/playmakerforum/index.php?topic=2603.0)

bye,

 Jean
Title: [SOLVED]
Post by: mickman 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