Forum rules - please read before posting.

CN Controls, Virtual Joystick integration?

edited July 2016 in Technical Q&A
Hi, everyone. I was wondering how to adapt the virtual joystick from this free asset (https://www.assetstore.unity3d.com/en/#!/content/15233), named CN controls, to use it with AC. Having used rewired in another project I'm working on, I tried to copy cat the method for the integration, using the delegates, but it didn't seem to work. (By the way, I'm not using rewired in this project). Here is the code I used: 

using UnityEngine;
using CnControls;
public class ACInputCNControls : MonoBehaviour
{
void Start()
{
//Call AC delegate for the joystick Axis
AC.KickStarter.playerInput.InputGetAxisDelegate = CustomGetAxis;
}

private float CustomGetAxis(string AxisName)
{
//get the axis from CNControls' joystick 
return CnInputManager.GetAxis(AxisName);
}
void Update ()
{
//this simply adds Accept and Cancel Functionality
if (Input.GetButtonDown("cancel")){
AC.KickStarter.playerInteraction.DeselectHotspot ();
AC.KickStarter.playerMenus.SetInteractionMenus (false);
}
}
}

Would anyone enlighten me with the correct way to do this? --EDIT: I'm assuming the code is wrong, or maybe the joystick script is the one that needs to be changed?. Also, I'm not sure if I'm using the wrong AC settings? I'm currently using direct control/ mouse and keyboard--  Anyways, like I've said before, I'm not much of a programmer, more of a designer/writer/artist. And I like the feel of the joystick in this asset. So, as always, any advice would be greatly appreciated.

PS#1: The game will have exploration and some light platforming and other stuff so regular drag movement setting is too imprecise.  Edit: And I can't seem to disable drag movement if I set the controls to touch?
PS#2: I'm hoping to make this game cross platform, the primary intended platform is mobile, but if possible I'd like to put it on PC too. So, if possible I'd like to keep the underlying inputs as Direct Control: Mouse and keyboard. But, if anyone has a better idea, I'll appreciate it.

Comments

  • Have you tried placing a Debug.Log in the CustomGetAxis function to see what's getting picked up?  The AxisName parameter will still need to make use of AC's input naming convention ("Horizontal" and "Vertical").
  • Eh? isn't it using CursorVertical and CursorHorizontal? or have I gotten confused with the names of the input axis? I currently have CN throwing CursorVertical and CursorHorizontal input, is that wrong?
  • edited July 2016
    Thanks, man! changing the Input names to "Horizontal" and "Vertical" did it. can't believe it was something so simple. I was under the impression the inputs had to have the same names as the ones in the list in the settings manager, was I wrong? 

    well, now it works, and it works great! Hey, maybe you could add the joystick to AC, seeing as its free, maybe the developer will give you permission? I've seen that happen in a few other paid assets.

    Anyways, thanks!
  • No problem.  Free or not, I prefer to keep the integration non-specific so that you can adapt it for any such asset.  But the input names are only necessary in the function parameters - the functions themselves can call upon whatever axes you like.
  • edited August 2016
    Alverik , Just wanted to say thank you for this useful joystick and integrations script.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.