Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Motion Controller

Discussion in 'Assets and Asset Store' started by Tryz, Feb 21, 2014.

  1. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,399
    You rock!! Thank you for doing this.

    You can now get @cygnusprojects document from the Vault. You'll find it under the "Read Me (Rewired for MC)" link.
     
    hopeful likes this.
  2. AiryKai

    AiryKai

    Joined:
    Apr 16, 2014
    Posts:
    52
    Hi, @Tryz . One more question...

    I'm interested in the Alt Camera Mode parameter in WalkRunStrafe motion. I don't quite understand how it works. Can I enable and disable it through code? Not only in the inspector.
     
  3. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,399
    Hey @AiryKai ,

    The Alt Camera Mode just determines if this motion will activate if the camera goes into aiming mode.

    You can set it through code using "ActivateWithAltCameraMode". However, it really won't do anything unless you're using a camera based on the IBaseCameraRig interface.

    Gory details below...
    This is an integration point so the MC and Adventure Camera & Rig (a camera asset I sell) would work together. In that camera (or any camera you create based on IBaseCameraRig) there is a property called "Mode". It's just an integer and I use it to say if we're in normal orbit mode (0) or aiming mode (2). What happens to the camera based on the mode is up to the camera.

    The "ActivateWithAltCameraMode" property of WalkRunStrafe (which is what "Alt Camera Mode" represents) basically determines if we'll look at the camera's "Mode" to determine if this motion should activate.

    So, if this property is set to true and the camera is in aiming-mode (or not 0), this motion will activate. This way, aiming causes the character to move out of something like WalkRunPivot and into this motion... WalkRunStrafe.

    I hope that makes sense.
     
  4. AiryKai

    AiryKai

    Joined:
    Apr 16, 2014
    Posts:
    52
    @Tryz, Thus, it works when the camera is in aiming mode. Right? But can I enable this mode in motion if the camera is not in aiming mode?
     
  5. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,399
    Right.

    No. Because of this...
    Code (CSharp):
    1. if (_ActivateWithAltCameraMode && mMotionController.CameraRig != null && mMotionController.CameraRig.Mode == 0) { return false; }
    If the "_ActivateWithAltCameraMode" is checked and the "Mode" == 0 (not aiming), this motion won't activate.

    What you can do is inherit from WalkRunStrafe and then override TestActivate() to have it work as you need. You'd just need to define what event/trigger activates this new motion. Hopefully this makes sense.
     
  6. AiryKai

    AiryKai

    Joined:
    Apr 16, 2014
    Posts:
    52
    Hello again, @Tryz !

    Thank you for the previous answer, you helped me to solve my problem.

    Another question... When I try to set a moving object as a target for NavMeshInputSource, the waypoint is placed under the character on which you have installed NavMeshInputSource. The path to the goal is not set while target is moving. If the target is stop, then it's okay.

    Any idea why this is happening?
     
  7. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,399
    I think I do. But, I've got some other changes for the NavMeshInputSource.cs that I haven't pushed yet.

    If you email me at tim@ootii.com, I'll send you the latest version. I believe it fixes the issue.
     
  8. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,399
    I'm looking for input...

    One of the things new users struggle with when using the AC and MC are Body Shapes and my lack of standard Unity colliders.

    Why do I use custom body shapes?
    1. Unity capsule colliders are limited to cardinal directions
    2. Unity capsule colliders can't be attached to multiple transforms
    3. Unity capsule colliders can't be dynamically rotated
    4. We get a lot more granular collision info from my approach

    Let's take a simple humanoid example. What you can do with Body Shapes is associate the bottom of a body shape capsule to the the root transform and the top of the body shape capsule to the head transform. If the character is just standing still... no difference; we can do that with a standard capsule collider. But...
    • If the character crouches down the body shape will automatically resize and rotate to character's true crouch.
    • If the character lies down in a prone position, the body shape capsule will "lie down" with the character.
    • If the character jumps, the body shape will automatically resize and move to represent the character's animation.
    So, to keep this flexibility and still auto-create Unity colliders, I'm thinking about doing something like this:



    I'll keep the body shapes, but allow you to check a box to auto-generate Unity colliders.

    For sphere body shapes, that's easy... SphereColliders.

    For capsule body shapes, I'll use a CapsuleCollider if I can... meaning you are using a simple capsule body shape. However, if you tie the body shape to different transforms or have non-cardinal setup... I'll use multiple SphereColliders and reposition them dynamically to match the animation of the character. Think of the spheres as an accordion that expand and contract as needed.

    What do you think?
     
    Last edited: Feb 23, 2016
    FargleBargle likes this.
  9. Tiny-Tree

    Tiny-Tree

    Joined:
    Dec 26, 2012
    Posts:
    1,314
    will this works for non humanoid characters too like for example dogs?
     
  10. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,399
    Yes.

    In the end, the body shape capsule is just two points and a radius. Unlike the Unity capsule collider, body shapes don't care about direction.

    Typically, for something like a dog I just use a single capsule body shape. I'd tie one end to its back hips (transform) and the other to its front "hips" or head (transform). The result is a shape that looks like a capsule laying on it's side.
     
  11. recon0303

    recon0303

    Joined:
    Apr 20, 2014
    Posts:
    1,634
    Not sure if this was asked before, and I have yet to try, but how well does Motion controller and Final IK work together? Any input would be great.. I have used Final IK alot, but not with Motion Controller since I just bought it not long ago.
     
  12. floraffray

    floraffray

    Joined:
    Jan 12, 2014
    Posts:
    5
    if this question has already been asked and answered could someone point me in the right direction?
    I just bought the motion controller 2 package, I want to import it into a project but I'd like to import just the necessary assets without any of the demo elements, can I just uncheck the demo folder? I tried doing so but it seemed it broke one of the scripts when I unchecked the folders I thought wouldn't be necessary in the import window.
     
  13. florianbepunkt

    florianbepunkt

    Joined:
    Nov 28, 2015
    Posts:
    45
    I use Motion Controller with Final IK. It plays together very well, I have encountered no issues when using Final IK with MC. What might be useful is to hook into the motion events in order to activate/deactivate some IK stuff like Grounder or LookAt when you're climbing for example.
     
    recon0303 and Tryz like this.
  14. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,399
    Hey @floraffray ,

    I just downloaded and imported. Here what I unchecked:
    ootii\ActorController\Demos
    ootii\MotionController\Demos
    Unity



    Everything imported and ran fine without these demo folders. If you do get an error, would you please email support@ootii.com? I'm curious to see what it is.
     
    BackwoodsGaming likes this.
  15. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,399
    Flying tutorial is up!

    I just released a video showing how to create a flying motion. At the end of the tutorial, you'll be able to hover in the air, fly forward like Superman, and share the motion with others.



    You can also grab it from the Vault.

    Enjoy :D
     
    Last edited: Feb 26, 2016
  16. FargleBargle

    FargleBargle

    Joined:
    Oct 15, 2011
    Posts:
    770
    This is great! Besides allowing characters to FLY, it pretty much covers everything you need to create any other new movement types, such as swimming for instance (you can even use the same idle/slow animation, without needing to trim it down to a simple pose first ;)). The only changes would be:
    • Replace the "flying" animation with one for "swimming" (also available from Mixamo :)).
    • Reduce the transition speed threshold between treading water (your "float" animation) and swimming.
    • Replace the "Jump" activator with an automatic trigger test, which would detect if the player is in a water volume, and the distance between the ground and the surface is greater than some preset "too deep to walk" value.
    • While not strictly required, I'd also like to replace the "Q" and "E" keys, used to control vertical motion, with a "pitch" control, using the right XBox stick, to provide smooth diving/surfacing movements. (I already have something like this on my flycycle, but it uses the "addtorque" command, which would need to be replaced by something that doesn't require a rigid body.)
    • Add a small "up" force to represent buoyancy when no counteracting input is being applied.
    ...and that's about it I think. All in all, this "To Do" list looks a lot more "doable" now that all the rest has been taken care of. Thanks Tim! :)
     
    BackwoodsGaming, Tryz and hopeful like this.
  17. FargleBargle

    FargleBargle

    Joined:
    Oct 15, 2011
    Posts:
    770
    And just to show how easy the first few steps are, there's this:



    I don't have proper water triggers yet, or a pitch control, but it was dead easy to substitute some swimming animations into Tim's Flying motion, and fiddle with the speed settings. Now that I've done that, I can see I also need to refine the controls/animation blends a bit, as switching from floating to swimming isn't very quick, and steering him with an XBox controller reminds me of the Iceberg scene in "Titanic". Still, it's a start. :)
     
    BackwoodsGaming and Tryz like this.
  18. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,628
  19. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,399
    @FargleBargle - Totally agree... Awesome!

    You're doing it the right way. Start small and just keep improving on that foundation.
     
    BackwoodsGaming likes this.
  20. borrowedLadder

    borrowedLadder

    Joined:
    Feb 11, 2015
    Posts:
    21
    Is there an easy way to access the "Is Gravity Enabled" part of the actor controller from script?

    I'd like to be able to activate/deactivate on my jumping animations (root driven animations, so the gravity is built into those already, right now the extra gravity from the Actor Controller makes him land too quickly).

    I still want gravity enabled most of the time to ground my player when I need to, if she steps off an obstacle etc

    If there is a way to change it from script I can add it into a simple State Behaviour script :)
     
  21. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,399
    Actually, the video for the Fly Tutorial (about 5 posts up) does exactly that. :)

    When you're in a motion, you could just do this in the Activate() function:
    Code (CSharp):
    1. mActorController.IsGravityEnabled = false;
    2. mActorController.OrientToGround = false;
    3. mActorController.FixGroundPenetration = false;
    If you're doing it from outside of a motion, you just need to grab the ActorController from the game object. You'd do that with something like this:
    Code (CSharp):
    1. GameObject lPlayer = GameObject.Find("SOME-NAME");
    2. ActorController mActorController = lPlayer.GetComponent<ActorController>();
    Just remember to reset the IsGravityEnabled when you don't need it off anymore.
     
  22. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,399
    I had someone ask what I'm using in the combat videos...


    In this latest video, I'm using:

    Actor Controller - Basic movement and shape of the character
    Motion Controller - Controls the animations: idle, walking, unsheathe, attacking, parrying, etc. (some are custom)
    Adventure Camera - Orbit based camera
    Mount Points - Holding the weapons
    Node Canvas - Goblin AI

    I've also got some custom "RPG Foundations". By that, I mean memory, senses, skills, etc.
     
    Last edited: Mar 2, 2016
    Bagnol and BackwoodsGaming like this.
  23. zeb33

    zeb33

    Joined:
    Nov 17, 2014
    Posts:
    95
    Could you please give any details of the node canvas integration? The latest motion controller integration pack from the NC site throws numerous errors on installing for me.
     
  24. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,399
    Hey @zeb33 ,

    The integration pack was put together by the NC guys based on older work. I haven't actually looked at it in a while.

    All of the MC + NC stuff I created for the video is new. I'll see about extracting it from my project and putting up on the Vault. It's still a work-in-progress, but it should get you past the error. It just may take me another week.
     
  25. zeb33

    zeb33

    Joined:
    Nov 17, 2014
    Posts:
    95
    Awesome thanks! Any AI type integration examples would be great - am also trying to hunt down the goblin demo with behavior designer..
     
    Tryz likes this.
  26. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,399
    I'm not sure the goblin demo is still around. That was done over 2 years ago with MC v1... I doubt it would still work.

    I'll see about doing a quick AI demo. In the end, I'm really just calling functions on the MC; ActivateMotion(), SetTargetPosition(), SetTargetRotation(), etc.
     
  27. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,399
    Node Canvas Integration

    @zeb33 had asked about using Node Canvas with the Motion Controller. So, I put together some NC actions and conditions as well as this video to get you started. :D



    You'll find the Node Canvas package up on the Vault. Just import it into a project that has the most recent MC and NC.
     
  28. Rusted_Games

    Rusted_Games

    Joined:
    Aug 29, 2010
    Posts:
    135
    @Tryz, you are amazing! I´ll take a look how can achieve the same using Behavior Designer, when comparing both products before purchase BD was a win over NC. :|
     
    Tryz likes this.
  29. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,399
    If I remember BD from way back, you should be able to copy 90% of the NC stuff over. I believe both BD and NC have similar structures... just some function name changes.
     
  30. zeb33

    zeb33

    Joined:
    Nov 17, 2014
    Posts:
    95
    Amazing, just what I needed. Thanks!!
     
    Tryz likes this.
  31. Goodgulf

    Goodgulf

    Joined:
    Jan 12, 2016
    Posts:
    59
    Hi Tim do you perhaps have a few lines of example code for such an event? I've been trying to use the MotionActivated event but below myMotionActivationEvent somehow doesn't get called. I've browsed to lots of delegate examples (including the Unity tutorial), I must be missing something obvious.

    Code (CSharp):
    1.  
    2.     void Awake () {
    3.     {
    4.         mc = GetComponent<MotionController> ();
    5.         mc.MotionActivated = this.myMotionActivationEvent;
    6.     }
    7.  
    8.     public void myMotionActivationEvent(int rLayer, MotionControllerMotion rNewMotion, MotionControllerMotion rOldMotion) {
    9.  
    10.         Debug.LogWarning ("RemoteMotionRPCs.myMotionActivationEvent(): motion gets activated");
    11.  
    12.     }
    13.  
    BTW I also found out at least one of the motions, Jump.cs, doesn't call the code to ensure the event is fired:
    Code (CSharp):
    1. public override bool Activate(MotionControllerMotion rPrevMotion)
    2. {
    3. ..
    4. ..
    5. return true;
    6. // should be?   return base.Activate(rPrevMotion);
    7. }
    Perhaps for a future fix (assuming it's was not intended)?
     
  32. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,399
    Hey @Goodgulf ,

    I just updated the documentation to include the MotionUpdated event (page 11) and full code.
    http://www.ootii.com/Unity/MotionController/MC2Guide.pdf

    I also ran the code and everything worked as expected. The only difference I can see between my code and yours is that I do "gameCode.GetComponent<MotionController>()". I wouldn't think the "gameCode." part would matter, but maybe it does.

    As for Jump, you're exactly right. Good catch. I double checked and I missed the following:
    Jump, Fall, and ClimbCrouch

    I'll fix those for the next update.
     
    Goodgulf likes this.
  33. Goodgulf

    Goodgulf

    Joined:
    Jan 12, 2016
    Posts:
    59
    Tryz likes this.
  34. FargleBargle

    FargleBargle

    Joined:
    Oct 15, 2011
    Posts:
    770
    Sorry I didn't respond earlier, but I guess I missed the significance of this post the first time I saw it. After seeing the recent question about body collider shapes in the Actor Controller thread, I ran a test to see what the collider on my character did when I jumped. I noticed that my usual capsule body collider and spherical foot collider changed to a stack of spheres as soon as I hit the "Play" button, so I re-read this post to see what was going on. I guess you're no longer just thinking about this but have actually implemented it. I'd been using my own capsule collider for collision detection, but was a bit concerned because it wasn't getting resized to match the one created by AC. After seeing that you'd implemented your own collision solution that took care of this, I got rid of my extra capsule collider, and am pleased to say everything still works without it. The trigger colliders in my scene that used to require the added capsule are all working just fine without it, so I'm giving this feature a belated thumbs up. :)
     
    Tryz likes this.
  35. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,399
    hahaha... Awesome!

    Actually, I'm glad to hear things are good. Sometimes I have to move forward and just hope that what I do doesn't burn everyone's game to the ground. :eek:
     
    FargleBargle likes this.
  36. Goodgulf

    Goodgulf

    Joined:
    Jan 12, 2016
    Posts:
    59
    So here's what I used it all for:



    It's not perfect but will do for now.

    In the past month I've been working on getting the Motion Controller to work with Photon Networking. It looks like I took a different approach than @Stan B. in the posts on page 8:
    • Each player is remote instantiated using a different prefab without the Motion Controller on it.
    • The remote player has its own Animator and animation scheme.
    • Both the local and the remote players have a script attached to them to be used for Remote Procedure Calls.
    • The local player catches the Movement Activated event and sends a RPC to the remote player to activate the animations (root motion = off).
    • The local player's position and rotation get streamed to the remote player.
    I've tried sending the Motion Controller states or the animator variables across the network but that didn't work for me.

    I'll see if I can write some of it down in a document to share in this thread for others to reuse.
     
    rubble1 likes this.
  37. Goodgulf

    Goodgulf

    Joined:
    Jan 12, 2016
    Posts:
    59
    Hi Tim

    on question related to the larger video, see the animation at 3mins:


    I've made two simple motions: death and cast spell. Using the motion builder manual all works fine bit for some reason in the middle of the cast spell animation the camera gets pulled towards the character. You can see it in the video. Also when I switch to scene view the camera rig is abruptly pulled towards the character. Any idea where I should start looking? I know it's little to go by..
     
    Last edited: Mar 12, 2016
    zeb33 likes this.
  38. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,399
    Looking good! Networking is probably the one thing I haven't touched in game development. So, it's cool that you (and Stan) have created solutions that work for you.

    I'm assuming you're using the Adventure Camera & Rig?

    Is the spell creating any kind of collision object? That would be my first guess as the ACR will shoot a ray to see if any object is between the camera and the anchor/target. If so, the camera will move forward.

    If there is, you can use the camera's "Collision Layers" to ignore any layer you deem it shouldn't.
     
    Goodgulf likes this.
  39. Goodgulf

    Goodgulf

    Joined:
    Jan 12, 2016
    Posts:
    59
    Yes, that's it. I'm indeed using the Adventure Camera Rig and the staff has its own collider. I added it to the "Character" layer and it now plays smoothly.
     
    hopeful and Tryz like this.
  40. zeb33

    zeb33

    Joined:
    Nov 17, 2014
    Posts:
    95
    This is looking real good, am looking into a Photon solution myself, will keep you posted. Any tips welcomed ;)
     
    Goodgulf and Tryz like this.
  41. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,399
    Unfortunately, I don't have any experience with networking. At some point, I'll probably need to dig into it. :)
     
  42. Goodgulf

    Goodgulf

    Joined:
    Jan 12, 2016
    Posts:
    59
    Hi Zeb33, you can find a first draft of my document here, for inspiration. I'll make it into a proper document next weekend.
     
  43. zeb33

    zeb33

    Joined:
    Nov 17, 2014
    Posts:
    95
    Hey Goodgulf - this is great stuff, will do same once my mp option is more complete. Thanks for sharing
     
    Goodgulf and Tryz like this.
  44. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,399
    montyfi likes this.
  45. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,538
  46. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,399
    Unfortunately, I don't own that asset. So, I can't give you specifics about it.

    Some things about the MC...

    The MC is a framework that is built to be expanded on. While it includes motions like walking, climbing, sneaking, balance beam, you can also add new motions to fit your specific game... like flying, swimming, etc. So, you're not locked into just what I provide.

    You can use it with humanoids and non-humanoids alike and you can use your own animations if you want.

    You can see some of the free expansions on the Vault:
    http://www.ootii.com/UnityMotionVault.cshtml

    One of my favorite features... walking on walls and ceilings. All of the features of the Actor Controller are part of the MC as the MC uses it under the hood.

    As noted in the product description, it includes the Actor Controller for free:
    https://www.assetstore.unity3d.com/en/#!/content/47923


    Hope that helps.

    https://www.youtube.com/playlist?list=PLw7Y7lUmqrILegveIWo5mYkGIv1Z1pQr5
     
    Bagnol likes this.
  47. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    909
    someone use easytouch i need know the best way for set input i got move

    return UnityEngine.Input.GetAxis("Horizontal") + ETCInput.GetAxis("Horizontal");

    at start i have try
    public com.ootii.Input.UnityInputSource input;
    input.MovementX += ETCInput.GetAxis("Horizontal");

    but no set {} in UnityInputSource

    any way for set the jump by overide i have the movie on youtube ^^ with the cat ^^

    at end if i use UnityInputSource

    i got

    The type or namespace name `UnityInputSource' could not be found. Are you missing a using directive or an assembly reference?

    sorry for my difficulty to understand some basic stuff
     
    Last edited: Mar 15, 2016
  48. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    909
    ok got this stuff

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. namespace com.ootii.Input
    5. {  
    6. public class EasyMotion : UnityInputSource
    7. {
    8.  
    9.     public com.ootii.Input.UnityInputSource input;
    10.     //input.MovementX += ETCInput.GetAxis("Horizontal");
    11.     public com.ootii.Actors.AnimationControllers.MotionController mo;
    12.  
    13.  
    14.         public override float MovementX
    15.         {
    16.             get
    17.             {
    18.                 if (!_IsEnabled) { return 0f; }
    19.                 return UnityEngine.Input.GetAxis("Horizontal") + ETCInput.GetAxis("Horizontal");
    20.             }
    21.          
    22.         }
    23.  
    24.         /// <summary>
    25.         /// Retrieves vertical movement from the the input
    26.         /// </summary>
    27.         public override float MovementY
    28.         {
    29.             get
    30.             {
    31.                 if (!_IsEnabled) { return 0f; }
    32.                 return UnityEngine.Input.GetAxis("Vertical") + ETCInput.GetAxis("Vertical");
    33.             }
    34.         }
    35.  
    36.  
    37.  
    38.         /// <summary>
    39.         /// Retrieves horizontal view movement from the the input
    40.         /// </summary>
    41.         public virtual float ViewX
    42.         {
    43.             get
    44.             {
    45.                 if (!_IsEnabled) { return 0f; }
    46.              
    47.                 float lValue = UnityEngine.Input.GetAxis("Mouse X") ;
    48.              
    49.                 // The mouse value is already frame rate independent (since it's basedon position). However,
    50.                 // we need the stick movement to compensate for the frame rate too. We'll make it's value relative
    51.                 // to 60FPS (1/60 = 0.01666)
    52.                 #if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
    53.                 if (_IsXboxControllerEnabled && lValue == 0f) { lValue = UnityEngine.Input.GetAxis("MXRightStickX") * (Time.deltaTime / 0.01666f); }
    54.                 #else
    55.                 if (_IsXboxControllerEnabled && lValue == 0f) { lValue = UnityEngine.Input.GetAxis("WXRightStickX") * (Time.deltaTime / 0.01666f); }
    56.                 #endif
    57.              
    58.                 return lValue;
    59.             }
    60.         }
    61.      
    62.         /// <summary>
    63.         /// Retrieves vertical view movement from the the input
    64.         /// </summary>
    65.         public virtual float ViewY
    66.         {
    67.             get
    68.             {
    69.                 if (!_IsEnabled) { return 0f; }
    70.              
    71.                 float lValue = UnityEngine.Input.GetAxis("Mouse Y");
    72.              
    73.                 // The mouse value is already frame rate independent (since it's basedon position). However,
    74.                 // we need the stick movement to compensate for the frame rate too. We'll make it's value relative
    75.                 // to 60FPS (1/60 = 0.01666)
    76.                 #if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
    77.                 if (_IsXboxControllerEnabled && lValue == 0f) { lValue = UnityEngine.Input.GetAxis("MXRightStickY") * (Time.deltaTime / 0.01666f); }
    78.                 #else
    79.                 if (_IsXboxControllerEnabled && lValue == 0f) { lValue = UnityEngine.Input.GetAxis("WXRightStickY") * (Time.deltaTime / 0.01666f); }
    80.                 #endif
    81.              
    82.                 return lValue;
    83.             }
    84.         }
    85.  
    86.         // Use this for initialization
    87.         void Start () {
    88.          
    89.         }
    90.      
    91.         // Update is called once per frame
    92.         void Update () {
    93.          
    94.          
    95.             //
    96.             //input.MovementY += ETCInput.GetAxis("Vertical");
    97.          
    98.          
    99.         }
    100.     }
    101. }
    102.  
     
  49. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,399
    Hi @kilik128 ,

    I haven't used EasyTouch, but it looks like you're close. :)

    Creating an "EasyTouch" input source is right. You're calling it "EasyMotion" which is totally cool. Although "EasyTouchInputSource" may be more descriptive.

    What you did in MovementX and MovementY is perfect. You're just replacing the guts of my functions with EasyTouch calls.

    UnityInputSource is in the "com.ootii.Input" namespace. So, wrapping the class like you're doing works or you can just add this to the top of your file:

    using com.ootii.Input;

    I don't understand what line 9 and line 11 are for. I don't think you need them.

    You shouldn't need an Update() function either. You really shouldn't need a "set {}". If it's something unique to EasyTouch, you can add anything you need.

    Mostly, you're just replacing my functions with ones that work with EasyTouch. So, based on what you've put so far, you might have a function like this:

    Code (CSharp):
    1.         public override bool IsJustPressed(string rAction)
    2.         {
    3.             if (!_IsEnabled) { return false; }
    4.  
    5.             try
    6.             {
    7.                 return ETCInput.GetKeyDown(rAction); // CHANGE TO EASY TOUCH CALL
    8.             }
    9.             catch
    10.             {
    11.                 return false;
    12.             }
    13.         }
    Just replace my "UnityEngine.Input" functions with your EasyTouch equivalents.

    You're doing good. You just have to fill out the other ones you need. The cool thing is that once you build this once, you can use it with all my assets.

    (I wish I didn't have to do this, but in order to support any input solution... I had to create something generic like the input source).
     
  50. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    909
    Year look just like that

    OK it's Work's !

    i'am back to school want see the tutorial fly
     
    Last edited: Mar 15, 2016
    Tryz likes this.