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. Dismiss Notice

[DEPRECATED] CN Controls - Mobile Joystick (Crossplatform)

Discussion in 'Assets and Asset Store' started by Kumo-Kairo, Feb 24, 2014.

  1. Kumo-Kairo

    Kumo-Kairo

    Joined:
    Sep 2, 2013
    Posts:
    343
    0.5
    There's a huge update in the assetstore. I've got a lot of feedback in the past year and decided to make a system that will satisfy all the needs (my needs too)
    It's now more easily convertible from Input. stuff and it doesn't break the standard input (which you get when you use a standard crossplatform system).
    It's totally new and is better than ever. A lot of people have already tested it (I've sent a bunch of packages to the people directly after conversations by e-mail)

    ---------------------------------------------------------------------

    0.3.3 version is finally on the AssetStore
    A few bugfixes, and more functionality is on the way
    https://www.assetstore.unity3d.com/en/#!/content/15233

    ---------------

    New 0.3.1 version is here, completely rewritten
    More about it in the #3 post

    ---------------
    Hi!
    I've made a free ready-to-use multitouch mobile joystick and decided to share.

    https://www.assetstore.unity3d.com/#/content/15233

    It has a arguable rendering method (through the perspective camera) but overall it's performance is much better than the Standard one. If you add assets from one atlas it will also batch them in one draw call - a feature that GUITexture doesn't have.

    I'm going to update it, so it will use separate orthographical GUI camera.

    It's also free once and forever.
     
    Last edited: Aug 13, 2015
  2. megabouda

    megabouda

    Joined:
    May 22, 2014
    Posts:
    1
    Hello Kumi-Kairo !

    Thank you very much for this free asset ! It is well made and well documented.

    I have a question. I would like to tweak your asset so that the joystick enables me to look around my scene like in a FPS view. Could you help me how to achieve this ?
    The character doesn't have to move, it is for architercural visualization purposes.

    Thank you in advance.

    megabouda
     
  3. Kumo-Kairo

    Kumo-Kairo

    Joined:
    Sep 2, 2013
    Posts:
    343
    Sorry for long response, I've lost track of this thread due to its unpopularity.

    I've updated to version 0.3.1
    It's now a completely rewritten set of controls, it includes Joystick (which now actually works), Touchpad and Throwable touchpad (keeps it's momentum). I've also added some menu items to create it with ease (more in README inside)

    You can grab the latest update at Github:
    https://github.com/KumoKairo/CNJoystick
    It's also open for contribution

    It's currently pending a review on the assetstore, so keep track of the update if you want to update it from the store
     
  4. Abalone

    Abalone

    Joined:
    Sep 23, 2014
    Posts:
    1
    Hello Kumi-Kairo,

    Thank you for your asset.
    I'm trying to implement it on a simple 2D game.
    I was suprised that GitHub version was really different from unity store version, but now i have the explanation :)

    I will wait the new version from the store.

    Thank you again :)
     
  5. Kumo-Kairo

    Kumo-Kairo

    Joined:
    Sep 2, 2013
    Posts:
    343
  6. mrgirose

    mrgirose

    Joined:
    Oct 14, 2014
    Posts:
    1
    Is there anyway we can rotate the touchzone area? I have a top down camera view, therefore I can only use the joystick along the x axis. I'm attempting to "rotate" the touch area so I can get input from the x and y axis. I'm very new to this :) Any ideas how I can do this?

    Thanks
    Graham
     
  7. Kumo-Kairo

    Kumo-Kairo

    Joined:
    Sep 2, 2013
    Posts:
    343
    Control camera has it's own x and y axis, it's independent of your main camera, so you don't have to rotate anything
     
  8. domoemmanuel99

    domoemmanuel99

    Joined:
    Dec 15, 2014
    Posts:
    1
    hi bro, your joysticks works super nice, but i want to know how to make a sprite looks where the joystick is pointing, like the image ; how i can communicate with you, because i want help, im new in this but i understand a bit of that, thanks in advance and sorry for my bad english :D
     

    Attached Files:

  9. Kumo-Kairo

    Kumo-Kairo

    Joined:
    Sep 2, 2013
    Posts:
    343
    There's a huge update in the assetstore. I've got a lot of feedback in the past year and decided to make a system that will satisfy all the needs (my needs too)
    It's now more easily convertible from Input. stuff and it doesn't break the standard input (which you get when you use a standard crossplatform system)
     
  10. reconp

    reconp

    Joined:
    Jan 12, 2017
    Posts:
    1
    cant speed up the object movement too slow
     
  11. Kumo-Kairo

    Kumo-Kairo

    Joined:
    Sep 2, 2013
    Posts:
    343
    Just as an original Input.GetAxis these methods return values from -1 to 1. Just multiply it by your speed, say, 15, and it will be ok
     
  12. chetan2

    chetan2

    Joined:
    Nov 6, 2015
    Posts:
    1
    Hey Kumo-Kairo,
    First OF All Thanx For This Plugin.
    I have Seen Your CN Controls Plugin ,
    It Looking Easy.
    Can You Tell Me How To Integrate I??
    I Wanna Use Joystick For Walkthrough
    Please Reply Me ASAP I Am Waiting

    You Can Revert Me On My Mail Id Also -chetan.argade@dgtechnologies.in
     
  13. Kumo-Kairo

    Kumo-Kairo

    Joined:
    Sep 2, 2013
    Posts:
    343
    Hi
    Just check the readme file and examples in the package, it has a lot of info and a step-by-step guide
    Take care
     
  14. kaisersam

    kaisersam

    Joined:
    Mar 31, 2016
    Posts:
    39
    Hello, thanks for your asset! it's really easy to implement.

    However, i have an issue to use it with the FPSController of the unity standard asset.

    i use 2 Joysticks, and after i mention the axis name in the field (Mouse X and Mouse Y for the camera axis), it doesn't work (for the left joystick, it works fine).

    How can i fix that?

    Thanks a lot.

    Regards, Sam.
     
  15. Kumo-Kairo

    Kumo-Kairo

    Joined:
    Sep 2, 2013
    Posts:
    343
    Yeah, that FPS controller seems to generate a lot of questions. Please take a look at MouseLook script in FPS Controller package. It has a LookRotation method on a line 31. There are two lines with CrossPlatformInput. Replace those with CnInputManager. Be careful though as CnInputManager in the Editor will work BOTH with the Mouse Input AND with the joystick input. This is intended for easier in-editor testing. You can use Unity Remote to test your joysticks and touchpads, this way the mouse won't be getting in your way.

    I will most definitely write a video tutorial on that and add an example of FPS controller to the package
     
  16. kaisersam

    kaisersam

    Joined:
    Mar 31, 2016
    Posts:
    39
    Thanks a lot, it works with this.

    But the behavior of the joystick are a bit strange.

    For example, with the left joystick (horizontal and vertical axis) when i move it, my character is moving, but the view is moving a bit also. And when i use the right joystick (Mouse X and Mouse Y), the view doesn't move really good.

    Also, when i use the joysticks, there is some jumps..
     
  17. Kumo-Kairo

    Kumo-Kairo

    Joined:
    Sep 2, 2013
    Posts:
    343
    It may greatly depend on a situation, but most of the time it's something with the setup with different parameters, different overlapping UI elements, different event system preferences. I tried making the package as easy and frictionless as I could, but of course there are lots of side cases in which it doesn't really work out (it's everything to do with Unity UI and built-in event system, you have to understand how that works too). You can send me a copy of your setup on a support e-mail (available in the package description) so I'll be able take a look at your specific case
     
  18. aibolith

    aibolith

    Joined:
    Apr 9, 2017
    Posts:
    9
    Hello. First of all, this is incredible package to be given for free, thank you very much.
    Now my question is probably simple, but I haven't found the answer in reasonable time, so I ask it. Is there a way to check if joystick is being pressed aside from measuring axis vector magntidue? Basically to use the touch zone of a joystick like a key.
     
  19. Kumo-Kairo

    Kumo-Kairo

    Joined:
    Sep 2, 2013
    Posts:
    343
    No, there's no built-in way to do that unfortunately. If you really need it, you can make that yourself though. Take a look at SimpleJoystick script in the package and add some SimpleButton behaviour in it, it should be pretty straightforward

    This behavior is in my local roadmap along with a first-person controller example. I hope to revisit this thing in the nearest future
     
  20. aibolith

    aibolith

    Joined:
    Apr 9, 2017
    Posts:
    9
    Understood, not a big deal though at the moment for me, magnitude check does the job, and editing SimpleJoystick looks pretty straightforward ineed. Thank you for quick answering!
     
  21. MarkCruz

    MarkCruz

    Joined:
    Jun 18, 2017
    Posts:
    2
    How can I speed up the Third Person? Movement speed doesn't work.
     
  22. Kumo-Kairo

    Kumo-Kairo

    Joined:
    Sep 2, 2013
    Posts:
    343
    There should be some kind of a variable that controls your character speed which you multiply by Time.deltaTime and by values from the joystick. Tweak that value and the character would move faster. If your character moves with a Mecanim root motion, you will only be able to move if faster if the animation will play faster.
    Keep in mind that character movement speed has nothing to do with on screen controls like it has nothing to do with the keyboard or a gamepad input.
    Also note that example controllers in the package are not really suited for real games and are just there for a scripting reference. Good third-person controllers sell for as much as 100$ on the assetstore and require a lot of tweaking too.

    Cheers and keep experimenting!
     
  23. alarm656

    alarm656

    Joined:
    Jul 6, 2013
    Posts:
    111
    Hi, Thank you for this cool asset. Touchpad Camera (Scene) => Canvas => Touchpad. Touchpad script rotates only with Horizontal Axis. No Vertical? (Control Move Axis = Both). Thanks

    Edit 1)

    Sorry, looks like I found why Vertical does not rotates. "RotateCamera" script. If I add
    var verticalMovement = CnInputManager.GetAxis("Vertical");
    rotating will be mess.

    Edit 2)

    I decided to use swipe for vertical axis, and I'm happy with it.
    But when I use Horizontal Axis and when I release my finger from UI Element I want my
    Camera Setup object to be automatically rotated to near solid value like 0*, 90*, -90*, 180* etc..
    I always want to have isometric view.
    Touchpad script:

    Code (CSharp):
    1. public void OnPointerUp(PointerEventData eventData)
    2.         {
    3.             _isCurrentlyTweaking = false;
    4.             if (!PreserveInertia)
    5.             {
    6.                 _horizintalAxis.Value = 0f;
    7.                 _verticalAxis.Value = 0f;
    8.             }
    9.  
    10.             Debug.Log ("I realised my finger");
    11.         }
    For Example: I'm rotating my Camera Setup object with UI Element that you provide. When I stop dragging (before realizing my finger) Camera Setup object will have original value like 29*, 67*, -210*.
    When I release my finger from Touchpad UI Element, if Camera Setup object has something -77* value I want it to be rotated to -90*. Like calculating which value is near.
    I'm so sorry and I know that this is not problem that you have to answer or support. But I'm new on calculating Math or another hard coding. I hope at least you'll give me an idea, thanks.
     
    Last edited: Jul 9, 2017
  24. Kumo-Kairo

    Kumo-Kairo

    Joined:
    Sep 2, 2013
    Posts:
    343
    Hi! I think working with a touchpad in your case is going against the grain. What you really need is, like you've said, a "swipe" controller. There was some kind of a free solution for that, https://www.assetstore.unity3d.com/en/#!/content/30111 ,check it out
    Cheers!
     
    alarm656 likes this.
  25. alarm656

    alarm656

    Joined:
    Jul 6, 2013
    Posts:
    111
    Thank you! Yes, for "swipe" i'm using that asset. I did change in your demo "Camera Setup" scene. Now, I don't rotating Camera, I'm rotating object itself. Parent - Horizontal, Child - Vertical. No problem now. Thank you again.
     
  26. DaveMero

    DaveMero

    Joined:
    Nov 4, 2017
    Posts:
    15
    Hy guy's , I have a problem with my controls. I use CNTouchpad to look around (FPC) and CNJoystick to move. If I look around and than I touch on a second position the camera jumping to other positions. I use this 2 codes on my player
    Code (CSharp):
    1. public float rotSpeed = 10f;
    2.  
    3. float rotX, rotY, RX, RY;
    4.  
    5. public Touchpad CNTP;
    6.  
    7. public GameObject Player, PlayerCam;
    8.  
    9. public void Update ()
    10. {
    11.      if(CNTP._verticalAxis.Value < 0 && CNTP._isCurrentlyTweaking == true ||
    12. CNTP._verticalAxis.Value > 0 && CNTP._isCurrentlyTweaking == true || (same for _HorizontalAxis.Value))
    13. {
    14.     rotX = input.GetAxis(''Mouse X'') *
    15.     rotSpeed;
    16.     rotY = input.GetAxis(''Mouse Y'') *
    17.     rotSpeed;
    18.  
    19.     RX -= rotY * Time.deltaTime * rotSpeed;
    20.  
    21.     RY += rotX * Time.deltaTime * rotSpeed;
    22.  
    23. PlayerCam.transform.localEulerAngles = new Vector 3(RX,0f,0f);
    24.  
    25. Player.transform.eulerAngles = new Vector 3 (0f,RY,0f);
    26.  
    27. RX = Math.Clamp(RX,-90,90);
    28. }
    29. }
    and I tested it with CNinputaxis with the same result!
    Now the player movement:
    Code (CSharp):
    1. public float speed = 3f;
    2.  
    3. Vector3 moveDir = Vector3.zero;
    4.  
    5. void Update ()
    6. {
    7.      moveDir.x = CnControls.CnInputManager.GetAxis
    8. (''Horizontal'');
    9.  
    10. moveDir.y = CnControls.CnInputManager.GetAxis
    11. (''Vertical'');
    12.  
    13. moveDir = transform.TransformDirection (moveDir);
    14.  
    15. moveDir *= speed;
    16. }
    I don't know what the problem is. Please help me
     
  27. DaveMero

    DaveMero

    Joined:
    Nov 4, 2017
    Posts:
    15
    and the same result with Unity crossPlatforminput (dualTouchControlls) :(
     
  28. DaveMero

    DaveMero

    Joined:
    Nov 4, 2017
    Posts:
    15
    I'm using 5.6.3f1
     
  29. Kumo-Kairo

    Kumo-Kairo

    Joined:
    Sep 2, 2013
    Posts:
    343
    I really should copy a standard unity FPS controller and make it a separate prefab, this FPS control topic pops up from time to time for quite some time now.
    To see what's wrong in your particular case I'll need a copy of your project, if it's possible. Pasted code doesn't provide enough info unfortunately
     
    DaveMero likes this.
  30. DaveMero

    DaveMero

    Joined:
    Nov 4, 2017
    Posts:
    15
    Thank you for your quick response. I'll try it
     
  31. DaveMero

    DaveMero

    Joined:
    Nov 4, 2017
    Posts:
    15
    Hmmm I don't know how I can handle this. Here is the package of my testproject
     

    Attached Files:

  32. DaveMero

    DaveMero

    Joined:
    Nov 4, 2017
    Posts:
    15
    If I walk and look around it is all ok. but when I start looking around and then start walking it does not work
     
  33. DaveMero

    DaveMero

    Joined:
    Nov 4, 2017
    Posts:
    15
    Ups there is no scene in there. Here is the right one
     

    Attached Files:

  34. victorkin11

    victorkin11

    Joined:
    Apr 20, 2013
    Posts:
    175
    Just saw this post, Thank for your asset even I haven't use it for long time, and It still get support.
     
  35. Kumo-Kairo

    Kumo-Kairo

    Joined:
    Sep 2, 2013
    Posts:
    343
    I got it running and experience the same problem in your example scene on a device. Using Unity Remote however doesn't allow me to tweak the touchpad at all. I'll take a look at it in the following two days and will write you back either here in this thread or via a direct message

    Is there a reason you don't use it anymore? :)
     
    DaveMero likes this.
  36. DaveMero

    DaveMero

    Joined:
    Nov 4, 2017
    Posts:
    15
    cool, thanks. I hope you find a reason for that:)
     
  37. orloKun

    orloKun

    Joined:
    Jan 9, 2016
    Posts:
    5
    Hi kumo-kairo, thanks for the asset, it has been really useful.
    I've been working on a 2d platformer and i cant solve the issue of moving and jumping at the same time.
    The jump button releases the horizontal axis buttons. Any suggestions?

    Thanks a lot!
     
  38. Kumo-Kairo

    Kumo-Kairo

    Joined:
    Sep 2, 2013
    Posts:
    343
    @orlocuario Hi! I've seen this issue from someone, and tried checking the built-in 2D platformer example - it allows jumping and moving at the same time. You should send me a copy of your project (preferably on a support e-mail support at nadezhdin.org) so I can take a look
     
  39. Kumo-Kairo

    Kumo-Kairo

    Joined:
    Sep 2, 2013
    Posts:
    343
    @DaveMero your example doesn't really comply with CnControls API. You don't need to reference touchpads or joysticks directly, it's all done via the CnInputManager API. In your case there are no calls to CnInputManager.GetAxis, it's all through standard Input API. This is why it's not working in the editor
    As for the jittery motion - it has something to do with the rotation code. It drops total rotation to zero somewhere. And I've also noticed that you multiply by rotSpeed twice (so rotSpeed becomes a quadratic parameter). I suggest taking a "touchpad camera" example and using that as a reference, and as you've said, CrossPlatformInputManager works the same, meaning that there's nothing really wrong with the input querying code itself.

    The way to go is to download Unity standard control package and replace needed Input API calls with CnInputManager calls, this way you'll get an instant working FPS controller.
    I agree that this package needs and FPS example as everyone is trying to implement their on from the ground up, and it's not the easiest thing to do. Even though it seems easy just to take the standard one and replace a few lines there. So I'm going to adapt the Unity's built-in FPS controller example and include it in the package. ETA for this is the end of November
     
    DaveMero likes this.
  40. DaveMero

    DaveMero

    Joined:
    Nov 4, 2017
    Posts:
    15
    ok thanks for your help. too bad that there are no good fps tutorials. I'll give it a try I'm looking forward to your fps example. Thanks a lot ;)
     
  41. marcell123455

    marcell123455

    Joined:
    Jun 18, 2014
    Posts:
    270
    @Kumo-Kairo

    Hi, I would like to know if there is any option to acess 2 inputs with one button? Thx for the great asset ;D
     
  42. Kumo-Kairo

    Kumo-Kairo

    Joined:
    Sep 2, 2013
    Posts:
    343
    You can just reference the same axis name from two different places. This will create an effect of using one button for two different things.
    There's nothing CnControls specific here - it's the same as working with the standard unity Input class
     
  43. unity_90bios90

    unity_90bios90

    Joined:
    Nov 30, 2017
    Posts:
    1
    Can you help me pls. I am noob in Unity. I made 2d game, and now I am trying to make it playable on Andoid using CN controls.
    I made that in void update and it warks exellent (if CnInputManager.GetButtonDown("Jump")) Jump();)
    But when i tried to remake my( if (Input.GetButton("Horizontal")) Run();) to (if (CnInputManager.GetAxis ("Horizontal")) Run();) it shows me float to bool mistake. What i am doing wrong
     
  44. saneinsylum

    saneinsylum

    Joined:
    Oct 28, 2015
    Posts:
    10
    Hey @Kumo-Kairo, so...
    I grabbed cn control, put it and a capsule with playmaker fps controls into a scene. It didnt register to the player. I grabbed the playmaker add-on, and got the movement good, but the mouselook isn't working. I read this thread, and you say to replace CrossPlatformInputManager with CnInputManager on mouselook. I look at the playmaker script, and nothing. I import the mouselook for the standard assets, edit it, and try to put it on my fps prefab. I get an error with something about monobehavior. I add that and get a different error. I decide to import the entire fps prefab to get this to work because the mouselook is already attached. I edit the two CrossPlatformInputManager in the rotate function, and get an error that it doesn't exist in current whatever. I try changing the CrossPlatformInput definition thing up top thinking it just has no idea what CnInputManager is because I tried calling from CrossPlatformInput.
    Long story short, no.
    The movement scripts in the playmaker package work great, but my camera still won't respond to the right joystick. Any chance I could get script for it?
     
  45. Kumo-Kairo

    Kumo-Kairo

    Joined:
    Sep 2, 2013
    Posts:
    343
    @saneinsylum I didn't really understand anything, but glad that at least Playmaker actions are working :)
    Let me clarify - you need to make first person controller to work with Playmaker and CN Controls?
     
  46. saneinsylum

    saneinsylum

    Joined:
    Oct 28, 2015
    Posts:
    10
    I'd actually prefer to use a capsule with a Cn Input axis vector, simple move and the playmaker mouselook action(or a Cn mouselook).
    My problem doesn't seem to be a problem with the playmaker package(I just assumed before that I would find a Cn mouselook in the playmaker package) but you also seem to have been having this problem with general mouselook scripts, and in this thread, it was recommended to change CrossPlatformInput into CnInput but that gave me two errors, so I also changed the "using" line up top to Cn too but got a new error.(with 5.6.4)
    Any chance of a Cn mouselook action or a mouselook script or something? I obviously don't know how to change what needs changed.
     
  47. Kumo-Kairo

    Kumo-Kairo

    Joined:
    Sep 2, 2013
    Posts:
    343
    Oooh I see, you need to replace the Playmaker's Mouse Look action with the CN Controls thing, now I understand.
    A mouse look can be replaced with CnInputManager.GetAxis with an axis mapped to both mouse movement in the Unity's Input settings of the project and to some on-screen joystick. This way you'll have a cross-platform input. MouseLook is not a crossplatform thing because there are usually no mice connected to mobile phones and it just won't work there in 99% of the cases. So what you really need is simple GetAxis thing with correctly set up input axis
     
  48. saneinsylum

    saneinsylum

    Joined:
    Oct 28, 2015
    Posts:
    10
    So... I've been trying to get cn getaxis working right, its still crazy. Better, but crazy. But the normal getaxis action doesn't work "right" either, so its not your problem. Thank you for your help, and thank you for your asset.
     
  49. LastChaos

    LastChaos

    Joined:
    Dec 9, 2013
    Posts:
    39
    Hi, I have a problem with the joystick, on the android the stick goes beyond the limits of the joystick and doesn't return to initial position. And Horizontal/Vertical axis values are always 0.
    Screenshot_20180217-145538.png
    Unity 2017.3.1p1

    P.S. in the editor mode everything works fine :\
     
  50. Kumo-Kairo

    Kumo-Kairo

    Joined:
    Sep 2, 2013
    Posts:
    343
    @LastChaos Hi! I have received a similar report via support e-mail and currently looking into it.