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

Virtual Controls Suite - Touch Controls for mobile devices now available

Discussion in 'Assets and Asset Store' started by seandanger, Jun 13, 2012.

  1. seandanger

    seandanger

    Joined:
    Jun 13, 2012
    Posts:
    39
    Hello everyone, I'm here to announce that the Asset store has just posted Bit By Bit Studios' Virtual Controls Suite, a set of control components for touchscreen devices.

    As a gameplay engineer, I'm often frustrated with lackluster control schemes in some of the mobile games I play, and I'm particularly obsessed with having perfect controls in my own games. Virtual Controls Suite is a set of control components including multi touch management, analog joystick, dpad, and face buttons that I hope will allow everyone to have perfect controls for their game. They're all very efficient and extremely customizable. They also support NGUI, EZGUI, and Unity's built in GUITexture format right out of the box.

    I hope you find them useful and I'm certainly open to any improvements or additions the community at large would want. Thanks for reading!

    Product page on our website for more info
    Asset store link
     
  2. rstehwien

    rstehwien

    Joined:
    Dec 30, 2007
    Posts:
    101
    Looks good, I like how it works with the mouse and touch. One more thing and it would be perfect... driving it with the keyboard as well. One thing I've noticed in messing around with the on screen joystick/button Unity provides is that when testing locally I really just want to be able to use the keyboard too (since I don't have a multi-touch monitor it is hard to mess with running and jumping at the same time for example).

    If you could (or there already is) some way to drive this by keyboard, I'll buy it in a second.

    Alternative is what I've been doing is writing a keyboard and joystick driver and having them send the same events to the character.
     
  3. seandanger

    seandanger

    Joined:
    Jun 13, 2012
    Posts:
    39
    Hey, thanks for the interest.

    Keyboard driving is a great idea! I'll add that today and update here once it's live =]
     
  4. rstehwien

    rstehwien

    Joined:
    Dec 30, 2007
    Posts:
    101
    Something I thought about while testing a cross platform app... couldn't press two buttons at the same time but wanted to make sure the behavior was the same across platforms (and was feeling too lazy to set it up on each machine and my device with unity remote installed was being played with by someone else).

    Oh... total side question. Does your site use wordpress and what theme (or did you make your own)? I recognized the scroll up button but have been slowly going crazy trying to setup my site before releasing my first tool.
     
  5. seandanger

    seandanger

    Joined:
    Jun 13, 2012
    Posts:
    39
  6. seandanger

    seandanger

    Joined:
    Jun 13, 2012
    Posts:
    39
    Alright, I've updated the suite to v1.1, each control now fully supports debug keys, which you can customize via the inspector!

    Here's a demo vid: http://www.youtube.com/watch?v=JByiuqGlYKE

    Hopefully the Asset Store team will post the update this week. You can always buy now and upgrade later too, of course =)

    Thanks for the great suggestion, rstehwien.
     
  7. voncarp

    voncarp

    Joined:
    Jan 3, 2012
    Posts:
    187
    I noticed you have a joystick control scheme with this product.

    Is it pretty easy to implement your control system with the standard mobile asset prefabs?
     
  8. seandanger

    seandanger

    Joined:
    Jun 13, 2012
    Posts:
    39
    Short Answer: Yes, it is easy to do. You can see it done from scratch using NGUI in the first few minutes of the tutorial video here: http://www.youtube.com/watch?v=zOdxCc4ZhWI

    And if you ever have any trouble, we're available via email, forums, and skype chat -- we strive for quick service.

    Longer answer:

    Using VCS is intended to be only as difficult as implementing your UI. So, if you are using GUITextures, you can use the example scene right out of the box. If you are using EZGUI and NGUI, you will need to take some steps to implement a joystick for those, as I can't provide those products along with my product.

    Still, all you need to do is add the appropriate AnalogJoystick script to a gameobject, set the "MovingPart" GameObject in the inspector, and go. So creating a joystick should only consist of adding the appropriate graphic to the screen using your UI of choice, then assigning it.

    The other difference is that the standard mobile asset joysticks use transform position for axis values of the joystick, instead of normalized values between -1.0 and 1.0, which is what VCS uses. So, in cases where you would have something like

    Code (csharp):
    1. mySpeed.x = joystick.position.x;
    you would use:

    Code (csharp):
    1. mySpeed.x = joystick.AxisX;
    Using a normalized value between -1.0 and 1.0 is how platforms like PS3 and X360 function. It's nice because you work with a value that is not dependent on the size of your graphics or joystick configuration.

    For instance, if you change your joystick movement range from a radius of 50 pixels to 100 pixels, your Axis values are still normalized between -1.0 and 1.0. But if you were using transform position as the default assets do, you would have double the amount of movement, so you'd have to change code every time you adjusted that movement range. Not the case with VCS.
     
  9. yezzer

    yezzer

    Joined:
    Oct 30, 2009
    Posts:
    143
    Hi!

    So far, so good with VCS!

    With the "position at touch location" option, is there a way of restricting where it will appear to an area of the screen? Ideally defined as a percentage rectangle.

    I currently have two analogue joysticks on screen - bottom right and bottom left - and would like them to only appear if there's a touch event on their respective side of the screen. Is this behaviour built in?
     
  10. seandanger

    seandanger

    Joined:
    Jun 13, 2012
    Posts:
    39
    Hey Yezzer!

    That's not a built in option, but shouldn't be too tough to add via modification of VCAnalogJoystickBase. Let me see what I can come up with.
     
  11. seandanger

    seandanger

    Joined:
    Jun 13, 2012
    Posts:
    39
    Ok, this is a pretty light addition :) I briefly tested on my machine (not device though) and I believe it behaves as you want. I'll roll this into the next feature update after more testing and profiling. But for now, you can add it yourself by modifying VCAnalogJoystickBase thusly:

    Add these 2 lines up near the other inspector variables, line 141:
    Code (csharp):
    1.  
    2. public Vector2 positionAtTouchLocationAreaMin = new Vector2(0.0f, 0.0f);
    3. public Vector2 positionAtTouchLocationAreaMax = new Vector2(1.0f, 1.0f);
    4.  
    Then, down in Update(), replace this section:
    Code (csharp):
    1.  
    2. // if positioning at touch location or we don't require collision, just take the first touch
    3. if (positionAtTouchLocation || anyTouchActivatesControl)
    4. {
    5.     SetTouch(tw);
    6.     break;
    7. }
    8.  
    With this:

    Code (csharp):
    1.  
    2. // if positioning at touch location or we don't require collision, just take the first touch
    3. if (anyTouchActivatesControl)
    4. {
    5.     SetTouch(tw);
    6.     break;
    7. }
    8.                
    9. if (positionAtTouchLocation)
    10. {
    11.     Vector2 positionPercentage = new Vector2(tw.position.x / Screen.width, tw.position.y / Screen.height);
    12.     if (positionPercentage.x < positionAtTouchLocationAreaMin.x || positionPercentage.x > positionAtTouchLocationAreaMax.x)
    13.         continue;
    14.     if (positionPercentage.y < positionAtTouchLocationAreaMin.y || positionPercentage.y > positionAtTouchLocationAreaMax.y)
    15.         continue;
    16.    
    17.     SetTouch(tw);
    18.     break;
    19. }
    20.  
    That should do the trick. The positionAtTouchLocationArea values are with respect to screen size, so you'll want them between 0.0 and 1.0, inclusive. Let me know how that works for you!

    -Sean
     
  12. voncarp

    voncarp

    Joined:
    Jan 3, 2012
    Posts:
    187
    I very pleased with how this control scheme integrates into my project. If anyone is having issues with a mobile control scheme or looking to reduce draw calls through NGUI, this is definitely the way to go.

    Outstanding author support. Very open minded to suggestions.
     
  13. seandanger

    seandanger

    Joined:
    Jun 13, 2012
    Posts:
    39
    Hello All,

    VCS version 1.3 has just been posted to the asset store and contains some great updates, most of which are suggested by our users.

    General Updates
    • Minor optimizations
    • Added deltaPosition property to VCTouchWrapper class

    More Joystick Options
    • Define area where positionAtTouchLocation is valid
    • Require exclusive touch
    Useful when you have 2 joysticks whose collision area overlaps. With this option checked, 1 touch will no longer activate both joysticks. Instead, it will activate the first joystick it collides with.
    • Use Late Update
    Causes a joystick to update during the LateUpdate Unity phase instead of Update. Use it on one of 2 joysticks to determine execution order easily.

    Thanks to our users for coming up with great features and I hope the readers out there give VCS a try if they haven't yet!
     
  14. RandAlThor

    RandAlThor

    Joined:
    Dec 2, 2007
    Posts:
    1,291
    Just bought your great asset
    :)

    and have a feature request.

    Could you implement a fade in, fade out solution for the joystick where we can choose if fading in general is possebile and how long the fade takes in and how long it takes to fade out out, please.

    Thank you for making this and the good video tutorial where you also show how to use this with ngui.
     
  15. seandanger

    seandanger

    Joined:
    Jun 13, 2012
    Posts:
    39
    Hi RandAlThor,

    Sure! If you're using NGUI, it shouldn't be too tough, I'll update here later today :)
     
  16. seandanger

    seandanger

    Joined:
    Jun 13, 2012
    Posts:
    39
    Okay, please make the following changes to VCAnalogJoystickNGUI.cs:

    At the top of the file, around line 20, add:

    Code (csharp):
    1.  
    2. public float fadeTime = 0.0f;
    3. private float _targetAlpha = 1.0f;
    4.  
    Then, replace the existing SetVisible() function (around line 88) with:
    Code (csharp):
    1.  
    2. protected override void SetVisible (bool visible, bool forceUpdate)
    3. {
    4.     if (!forceUpdate  _visible == visible)
    5.         return;
    6.        
    7.     _movingPartVisible = visible  !hideMovingPart;
    8.     _visible = visible;
    9.        
    10.     _targetAlpha = _visible ? 1.0f : 0.0f;
    11. }
    12.  
    Finally, override the base class Update() method to control the alpha fading. Just add this code:
    Code (csharp):
    1.  
    2. protected override void Update ()
    3. {
    4.     base.Update ();
    5.        
    6.     if (_movingPartSprite.alpha < _targetAlpha)
    7.     {
    8.         // fade in
    9.         _movingPartSprite.alpha = fadeTime > 0.0f ? Mathf.Clamp01(_movingPartSprite.alpha + Time.deltaTime / fadeTime) : 1.0f;
    10.     }
    11.     else if (_movingPartSprite.alpha > _targetAlpha)
    12.     {
    13.         // fade out
    14.         _movingPartSprite.alpha = fadeTime > 0.0f ? Mathf.Clamp01(_movingPartSprite.alpha - Time.deltaTime / fadeTime) : 0.0f;
    15.     }
    16. }
    17.  
    Now, in the inspector for your NGUI Analog Joysticks, at the bottom, you'll see a variable called "Fade Time". This is how long the joystick takes to fade in and out in seconds. If set to 0, the joystick will instantly show or hide (like it does by default).

    The code I posted only fades the "moving part" of the joystick. If you have a "base part" you'd also like to fade, simply get a reference to the base part's sprite during the Init() function (just like it's already done for the moving part), and fade it along with the moving part fade code above. I can help with that if you need :)

    Also, make sure the material for your joystick atlas is using a shader with color. The atlas in the example scene that comes with VCS uses the Unlit Transparent shader by default. You'll need to change that to Unlit Transparent Colored if you want to see the fade happen.
     
    Last edited: Aug 1, 2012
  17. RandAlThor

    RandAlThor

    Joined:
    Dec 2, 2007
    Posts:
    1,291
    Thank you Seandanger, i will try this later.
    I have one new question.
    How can i rotate an orbiting camera around the player object with a joystick?
    I mean it that way it rotates around the y axis when i slide left and right and when i slide uo and down it should use the x axis but with restrictet ancles so the camera do not go to the ground?
     
  18. seandanger

    seandanger

    Joined:
    Jun 13, 2012
    Posts:
    39
    In a script in your game, perhaps where you control your camera, simply read the AxisX and AxisY values from the joystick during Update() and do what you want with them. Take a look at VCTestSuite.cs in the example scene to see examples of working with the joystick. Here's another quick example of what you might want to do:

    Code (csharp):
    1.  
    2. public Transform cameraTransform;
    3. public float lookSpeed = 1.0f;
    4.  
    5. void Update()
    6. {
    7.     VCAnalogJoystickBase joy = VCAnalogJoystickBase.GetInstance("stick");
    8.     if (joy != null)
    9.     {
    10.         // rotate camera around its Y axis based on X input from joystick
    11.         cameraTransform.RotateAroundLocal(new Vector3(0.0f, 1.0f, 0.0f), joy.AxisX * lookSpeed * Time.deltaTime);
    12.  
    13.         // rotate camera around its X axis based on Y input from joystick
    14.         cameraTransform.RotateAroundLocal(new Vector3(1.0f, 0.0f, 0.0f), joy.AxisY * lookSpeed * Time.deltaTime);
    15.     }
    16. }
    17.  
    All you really need from VCS are the input values. How you treat the input is up to you and not really controlled with VCS. So, if you want to restrict the angles your camera can rotate between, just check its rotation and clamp it between the values you want. Or, you could add an if statement above the 2 RotateAroundLocal() calls in the code above, making sure you aren't at the limit of your rotation, before rotating.

    For more on rotation, you'll probably want to read up on some of the common functions from Quaternion. Euler would probably do the trick for you: http://docs.unity3d.com/Documentation/ScriptReference/Quaternion.Euler.html . Also, Unity has example projects like AngryBots and Penelope (which includes a tutorial) on working with 3D cameras. Here's Penelope in case you find it useful: http://unity3d.com/support/resources/tutorials/penelope .

    Let me know if I can help further ;)
     
  19. Likos1

    Likos1

    Joined:
    Aug 12, 2012
    Posts:
    14
    I will probably purchase this. I do have a few questions. I plan on making a FPS for mobile with this. Lots of mobile FPSs have a control system where there there is a moving stick on the left, a shooting button on the right, and the ability to aim by moving your finger around in the center of the screen. Is there such a layout with this pack?
     
  20. seandanger

    seandanger

    Joined:
    Jun 13, 2012
    Posts:
    39
    Hey Likos1, thanks for your interest!

    You can definitely have this setup with VCS, I know of a few users who employ the same configuration in their games. You have 1 joystick with normal settings for your movement, another visually hidden "any touch activates control" joystick for your camera (with "require exclusive touch" checked), and a button in the scene. I'd be happy to setup an example scene illustrating the setup as well.
     
  21. replay11

    replay11

    Joined:
    Dec 24, 2007
    Posts:
    168
    Hi, I just purchased your product and after installation of the package I got a few compiler errors...

    error CS0101: The namespace `global::' already contains a definition for `UIButton'
    error CS0101: The namespace `global::' already contains a definition for `UIPanel'
    error CS0101: The namespace `global::' already contains a definition for `SpriteRoot'
    error CS0101: The namespace `global::' already contains a definition for `SimpleSprite'

    I have NGUI, but I have not installed it yet. Could that be the reason? Any suggestions on how I can fix this?
     
  22. seandanger

    seandanger

    Joined:
    Jun 13, 2012
    Posts:
    39
    Hi replay11 =)

    We're covering this one in email now, but for forum record, it seems to be a class naming issue with having EZGUI and NGUI installed at the same time. I'll update here once we've fixed the issues.
     
  23. replay11

    replay11

    Joined:
    Dec 24, 2007
    Posts:
    168
    Hi Sean,

    Thanks for the awesome support! My issue is resolved now. I removed EZGUI from my project and will be using NGUI instead. All is good now.
    :)

    www.replay11.com
     
  24. seandanger

    seandanger

    Joined:
    Jun 13, 2012
    Posts:
    39
    Just a quick note to say that version 1.4 has been released on the Asset Store.

    This release adds Playmaker support via PM's GetProperty Actions, adds some new member properties to Joystick, and fixes some minor bugs. The product is selling well and getting great feedback. Thanks to all the users who have tried it out and suggested feature additions!
     
  25. stety2

    stety2

    Joined:
    Aug 17, 2012
    Posts:
    58
    deleted
     
    Last edited: Oct 22, 2012
  26. guoyuan

    guoyuan

    Joined:
    Nov 18, 2012
    Posts:
    3
    hi I want to use two AnalogJoystick,can you help me? like the pict $未命名.jpg ure I don't know how to add AnalogJoystick,where can I fix?
     
  27. seandanger

    seandanger

    Joined:
    Jun 13, 2012
    Posts:
    39
    Hi guoyuan.

    You can open one of the example scenes in VirtualControls/Examples/Scenes , such as the guiTextureSuite.unity file. That has a joystick, dpad, and button created for you already. Then, just copy the Joystick and paste it into your own scene twice.

    If you need more help than that, please ask support questions on our support forum here: http://bitbybitstudios.com/forum/
     
  28. guoyuan

    guoyuan

    Joined:
    Nov 18, 2012
    Posts:
    3
    thank you ,this question has resovled ,but I have new problem, when I import MouseLook which is in unity3d demo javascript , It dosen't work ,and print: Assets/VirtualControls/NGUI/Scripts/Tweening/UITweener.cs(13,35): error CS0246: The type or namespace name `IgnoreTimeScale' could not be found. Are you missing a using directive or an assembly reference? and so on ,Is this MouseLook contradict with VirtualControls ?shall I do ?
     
  29. ShinyTaco

    ShinyTaco

    Joined:
    Sep 4, 2012
    Posts:
    70
    Hi Sean,

    Just bought VCS, thank you. So far it looks great.

    I'm trying to control UltimateFPSCamera with it. I've managed to add the joystick to the UFPSCamera. When I demo it on the iPhone it the joystick works and I get the XY info on the top left. The gun fires when I touch the joystick as well.

    Do you know how I would go about getting the UFPSCamera to move with the joystick?

    I took a wild stab in the dark and added:

    public CharacterController FPSPlayer;

    to VCSuiteTest.cs

    ...didn't work.

    How can I get your asset to work with UFPSCamera?

    Thank in advance for any help!
     
  30. seandanger

    seandanger

    Joined:
    Jun 13, 2012
    Posts:
    39
    Hey ShinyTaco,

    Thanks for purchasing! I'm happy to help out if I can. I generally want to keep this thread for announcement and pre-purchase questions, so in the future please ask your support related questions over at our official support forum for VCS.

    I'm not familiar with UFPSCamera, so I can't say exactly what you need to do. However, using a VCS joystick to control any type of camera should be very similar to controlling the camera with the mouse or Unity's built in joysticks or touchpad, for instance. Have you taken a look at the VCFirstPersonControl.txt script included in the Examples/Scripts folder in VCS? That's a working sample (that interfaces with Unity's CharacterController) of a first person scene with 2 joysticks -- one for movement and one for camera rotation. If you change that file extension to .js, (and setup VCS for use with javascript, see readme/FAQ for details), you can use that script as it is.

    If that's not what you're looking to do, can you provide more details on how exactly you want to interact with this camera?

    Let me know if that helps.
     
  31. RSH1

    RSH1

    Joined:
    Jul 9, 2012
    Posts:
    250
    I'm trying to use VCFirstPersonControl but it's giving me a compilation error. I've renamed it to .js and moved the folder to /plugins/ yet it is saying

    Assets/Plugins/VirtualControls/Examples/Scripts/VCFirstPersonControl.js(122,28): BCE0018: The name 'VCAnalogJoystickBase' does not denote a valid type ('not found').
     
  32. Finjitzu

    Finjitzu

    Joined:
    Sep 8, 2011
    Posts:
    160
    Last edited: Dec 8, 2012
  33. seandanger

    seandanger

    Joined:
    Jun 13, 2012
    Posts:
    39
    @RSH: looks like you found the support forums, and we've answered that question here: http://bitbybitstudios.com/forum/discussion/32/vcfirstpersoncontrol-error.

    @Finjitzu: I have never seen that particular error with importing VCS before, but I have seen that error when moving files and something other than Unity has a project file open, so that's not really a VCS error, more of a Unity / Windows issue. Perhaps you have some anti virus software or similar? Try closing programs that could have that file open, and restarting Unity and trying again. If that fails, try restarting your computer and trying again. Some of the advice in that thread seems pertinent too, especially the Windows Indexing Service one.

    Good luck and let us know how it goes!
     
  34. Finjitzu

    Finjitzu

    Joined:
    Sep 8, 2011
    Posts:
    160
    Thanks for the reply/ Running Unity as an Administrator fixes the issue. Got it in my project! Can't wait to start implementing it.
     
  35. I am da bawss

    I am da bawss

    Joined:
    Jun 2, 2011
    Posts:
    2,574
    Just wondering, is Virtual Contyrol Suite on sale right now?? On the Asset Store Input/Out section it says its on sale at $22.50 right now, but when I click on it says $45. Just wondering that's all. I would probably get it if its $20.
     
  36. Finjitzu

    Finjitzu

    Joined:
    Sep 8, 2011
    Posts:
    160
    So I have to say I'm pretty happy with this package so far. Took me one night to convert my project to Virtual Controls, which has saved me a ton of time. Very easy to impliment, so that's good. Had one snag though so I thought I'd put it in here in-case anyone else runs into it.

    The package includes NGUI free version and since I already had the Standard Edition this was causing some confusion in Unity. It was actually causing my builds to crash on load. I was pretty freaked out seeing like 40 warnings in the console. If you already have NGUI in your project, delete NGUI from the Virtual Controls folder. Deleting NGUI Free edition from the Virtual Controls suite fixes all warnings and my builds work now :)

    Another glitch I seem to be having is with the Analog Joystick. The front widget sometimes seems to get put behind the back widget. Not sure what's causing it, seems random right now. But I'll be doing some more testing after work today.

    Overall great package, thanks!
     
    Last edited: Dec 10, 2012
  37. seandanger

    seandanger

    Joined:
    Jun 13, 2012
    Posts:
    39
    It is supposed to be on sale, looks like today it isn't showing up as on sale in the Asset Store, though it has been for the rest of the month. I'd wait for a day to see if Unity works that out, otherwise you can purchase it at the sale price via paypal from our website, linked in my signature.

    @Finjitzu: Great to hear! Thanks for the notes. Yes the existing NGUI thing gets people from time to time. Hopefully you noticed the section in the readme or the FAQ about that without too much freaking out! :)

    The front widget moving behind the back widget can happen sometimes based on your particular setup for various reasons, most likely an NGUI issue. If both sprites are on the same atlas, make sure the front one is at a higher depth than the back one (not the same depth). If they're on separate panels, make sure the back panel has a higher (positive) Z transform position than the front panel. Let me know if that helps. If not, I'm happy to take a look and try to reproduce the issue.
     
  38. GrooGadgets

    GrooGadgets

    Joined:
    Apr 2, 2009
    Posts:
    71
    Hey there,

    I bought your asset this week and am overall impressed with its functionality and ease of use.

    I would like to suggest an improvement to the joystick; would you be able to add dampening to the joystick values so that when the user release the joystick it doesn't just abruptly snap back to zero?

    I am creating a twin stick shooter similar to Geometry Wars and would love to have my ship come to a halt smoothly over a pre determined amount of time.

    Another feature I would really like to see implemented is a "remember joystick angle" function. Currently when the user releases the right joystick it snaps back to the default value of zero. I have a 360 degree gun turret assigned to the right stick and it looks unnatural snapping back to zero when the stick is released.

    Would it be possible to implement these enhancements?

    Cheers,

    Simon
     
  39. seandanger

    seandanger

    Joined:
    Jun 13, 2012
    Posts:
    39
    Hi Simon, thanks for the purchase, glad you like it so far!

    We don't have either of those features out of the box, but VCS is written to be easily extensible, so I can help you make some edits to the joystick so it behaves how you like. Can you email me at support@bitbybitstudios.com so I can send you some code? Also, please let me know which UI solution you're using for your controls.

    That said, for your ship coming to a halt smoothly, that might be better achieved via code instead of modifying the joystick. I think it's better for the user if the virtual joystick behaves as a physical joystick would, which is snapping back to the center once they let go of it. To halt your ship smoothly, if your current movement code looks something like this:

    Code (csharp):
    1.  
    2. public float moveSpeed = 5.0f;
    3.  
    4. void Update()
    5. {
    6.     // move ship based on joystick input
    7.     shipTransform.Translate(moveSpeed * Time.deltaTime * joystick.AxisX, moveSpeed * Time.deltaTime * joystick.AxisY, 0.0f);
    8. }
    9.  
    Instead of using the joystick input values directly, you use an intermediate variable which you can then dampen:

    Code (csharp):
    1.  
    2. // these are additional class variables you would need to add
    3. public Vector2 currentSpeed = new Vector2();
    4. public float dampenDurationSeconds = 2.0f; // how many seconds it takes for ship to stop moving after input has ceased
    5. private float _accumulation = 0.0f; // how much dampening time has elapsed (value is 0 thru 1)
    6.  
    7. void Update()
    8. {
    9.     if (joystick.Dragging) // user is touching joystick
    10.     {
    11.         // update the currentSpeed vector using input from the Joystick.
    12.         currentSpeed.x = moveSpeed * Time.deltaTime * joystick.AxisX;
    13.         currentSpeed.y = moveSpeed * Time.deltaTime * joystick.AxisY;
    14.         _accumulation = 0.0f; // set dampening time to 0 since we're using the joystick
    15.     }
    16.     else // user has let go of joystick -- it snaps back to center, but we dampen our ship's movement
    17.     {
    18.         // linearly interpolate (lerp) the current speed back to 0
    19.         _accumulation += Time.deltaTime / dampenDurationSeconds;
    20.         currentSpeed.x = Mathf.Lerp(currentSpeed.x, 0.0f, _accumulation);
    21.         currentSpeed.y = Mathf.Lerp(currentSpeed.y, 0.0f, _accumulation);
    22.     }
    23.  
    24.     // finally, perform your movement as before, using currentSpeed.
    25.     shipTransform.Translate(currentSpeed.x, currentSpeed.y, 0.0f);
    26. }
    27.  
    This way, your joystick behaves like a joystick should, and your ship behaves like a ship should! :) Let me know if that makes sense. And if you'd still like the joystick to dampen itself back to the center over a specified duration, I have some code for you if you email me.

    As for holding the joystick in place once its released, that can be done pretty easily as well, but I'm not sure what specific behavior you would like to see. Are you wanting just the visual aspect of the joystick to remain in place, just the input to remain in place, or do you want both the input and the visual position to remain in place? Again, this is another thing you could do via your own code that controls the turret as well:

    Code (csharp):
    1.  
    2. void Update()
    3. {
    4.     if (joystick.Dragging) // user is touching joystick
    5.     {
    6.         SetTurretAngleUsingJoystickInput(); // your code that sets the turret angle would be in this function
    7.     }
    8.     else
    9.     {
    10.         // do nothing - just stay at the position we were at when the user last touched the joystick!
    11.     }
    12. }
    13.  
    Same as before though, if you would like the joystick itself to stick in place for you, I'm happy to help you make some edits for that. Just contact me at support@bitbybitstudios.com so I can send you some source code!

    Thanks!

     
  40. barry1978

    barry1978

    Joined:
    Feb 16, 2013
    Posts:
    10
    Hi,

    i'm using the vcs joystick in one of my iOS games to move a spaceship(rigidbody) around in X and Y axis, with the camera following it.
    While testing in Unity on my mac, controls are smooth and all is looking darn great :)

    However, when i test the same scene on my iPhone the game glitches, and it does it every time
    after i used the joystick for the first time, have let go of it, and then touch it again.
    It looks like the game freezes for just a millisecond and isn't smooth at all :(
    As long as i keep touching the joystick and move around there's no problem.
    I've tried the guitexture one and the NGUI one but it happens with both of them.

    Do you know what might be causing this ?
     
    Last edited: Nov 22, 2013
  41. seandanger

    seandanger

    Joined:
    Jun 13, 2012
    Posts:
    39
    Hey barry1978,

    VCS by itself shouldn't cause any lag like you've described, but any number of things in your game could be causing trouble like that, including the way you're reading input from the controls. Perhaps you could disable VCS and trigger the ship movement via code to see if the issue still happens, or have you done that already? Also, if you have a Unity Pro license, using the Profiler would be your best option to determine the source of the spike.

    Otherwise, I can only guess without seeing your code or your project. Could you contact me at support@bitbybitstudios.com or at our support forums for further assistance? I'll also need your Asset Store Invoice # please. Thanks.
     
  42. tongchimlang

    tongchimlang

    Joined:
    Mar 12, 2014
    Posts:
    16
    How can i fix it? Please help me!
    Thank
    NGUI V. 3.6.6
     
  43. seandanger

    seandanger

    Joined:
    Jun 13, 2012
    Posts:
    39
    Hey tongchimlang, off the top of my head, sometimes that happens when you change the folder location of the asset. If you import it as-is from the VirtualControSuitePackages file, it should work fine. The default location is in Assets/Plugins/VirtualControls.

    If that doesn't work, please use our support forum (linked below) for additional help. And please make sure to include your asset store invoice # so we can verify your purchase. Thanks!

    http://bitbybitstudios.com/forum/categories/virtual-controls-suite-support
     
  44. lazerdarts

    lazerdarts

    Joined:
    Sep 12, 2014
    Posts:
    6
    im having similar issues and when i click the link your website is not working?
     
  45. seandanger

    seandanger

    Joined:
    Jun 13, 2012
    Posts:
    39
    Hi lazerdarts, it should be working fine (it works from multiple machines here at my office). Please try again, or just email us at support@bitbybitstudios.com, and we can help. Thanks.
     
  46. draganstamenkovic

    draganstamenkovic

    Joined:
    Sep 27, 2014
    Posts:
    3
    Hi seandanger!

    I'm building 3rd person game with isometric camera. And i purchase your VC Suite from Unity Assets Store. I implement movement to my character. But i want the character to be rotated in (Y axis) the same direction in which he moves with joystick. So I spend like 2 days with joy.AngularDegrees working on rotation. But the problem is that the angular degrees are not going in the same angle as unity Y coordinate. So i get weird rotation when trying to do that. I tried like 20 ways to this properly and non of them worked correctly.

    Note:

    - Model is exported from Blender.
    - I'm using NGUI v2

    All i need from you is to tell me how can i make player look in the same direction as he moves???

    So do u have any explanation how can i do this? Which code to add, i really need this urgently! Thanks in advance
     
  47. seandanger

    seandanger

    Joined:
    Jun 13, 2012
    Posts:
    39
    Hi Dragan, thanks for buying VCS. I see that you've contacted me on Skype, so I'll try to get back to you there. Otherwise, I usually perform support for the product at our support forum.