Forum rules - please read before posting.

First person controller touch

hi chris
i have problem to use touch and joystick on android platform i want some controller like shadowgun or dead trigger i use playmaker for shooting system and ac for AC Stuff .
i use first person for movement method and touch screen for input method but when i export my project non of joystick or lookaround camera not worked (like mouse look in pc platform) but if i change input method to mouse and keyboard then lookaround  is worked but joystick not working . i use CNcontrol joystick and latest version of ac (1.59a) and unity (2017.1.1 ) and all input are same as your fist person video tutorial .

Comments

  • Two control assets won't "just work" together automatically - you have to include an integration script that gets them talking to one another.

    One specifically for CNControls has been posted on the wikia here - have you tried it?
  • tnx Chris yes i used that integration script for CNControls and its working just fine but my problem is whit move camera around whit draging finger on screen so ac cant do that one for me ? becuse iam not generally a programer so if AC cant do that one for me do you know any way to fix that problem for me any free or paid asset or can i do that whit my playmaker?
  • When your Input method is set to Touch Screen, and your Movement method is set to First Person, an option under "Movement settings" named First person movement will appear.  Have you tried setting that to Touch Controls Turning Only?

    I'm confused because you're looking to use both AC and CNControls for input - could you explain more clearly what it is exactly you're trying to achieve?
  • edited September 2017
    when i use Touch Controls Turning Only then i can look around by dragging on screen but then CnControls not working for moving character himself i want somthing like this screenshot Screenshot 
    am i doing wrong about using CnControls for movement joystick and Ac touch system for control camera rotate together ?
  • I should think you'd have to use CNControls for all of that - or at least some kind of custom set up, because AC doesn't have a "split-screen input" option.

    The wiki script allows overriding of AC's use of Input.GetAxis - which is used to read movement axes.  However, free-aiming has its own special delegate - InputGetFreeAimDelegate.

    If you can use CNControls to create that right-hand area and map it to an axis named e.g. "FreeAim", this change to the wiki script should allow you to make use of it:

    using UnityEngine;
    using CnControls;

    public class ACInputCNControls : MonoBehaviour
    {

      void Start()
      {
        //Call AC delegate for the joystick Axis
        AC.KickStarter.playerInput.InputGetAxisDelegate = CustomGetAxis;

        //Call AC delegate for freeaiming
        KickStarter.playerInput.InputGetFreeAimDelegate = CustomFreeAim;
      }


      private float CustomGetAxis(string AxisName)
      {
        //get the axis from CNControls' joystick
        return CnInputManager.GetAxis(AxisName);
      }


      private Vector2 CustomFreeAim (bool cursorIsLocked)
      {
        //get the axis from CNControl's "FreeAim" axis
        return CnInputManager.GetAxis("FreeAim");
      }

    }

  • i think it should be:

    AC.KickStarter.playerInput.InputGetFreeAimDelegate = CustomFreeAim;

    not:

    KickStarter.playerInput.InputGetFreeAimDelegate = CustomFreeAim;

    if i am not wrong , after i modifying the wiki script like you said then i get to this error:

    ACInputCNControls.cs(27,25): error CS0029: Cannot implicitly convert type `float' to `UnityEngine.Vector2'
  • edited September 2017
    Quite right.  Since the free-aiming is a 2D axis, you'll need to create 2 axes in CNControls - "FreeAim X" and "FreeAim Y" for the horizontal and vertical axes respectively.

    using UnityEngine;
    using CnControls;
    using AC;

    public class ACInputCNControls
    : MonoBehaviour
    {

      void Start()
      {
        //Call AC delegate for the joystick Axis
        KickStarter.playerInput.InputGetAxisDelegate = CustomGetAxis;

        //Call AC delegate for freeaiming
        KickStarter.playerInput.InputGetFreeAimDelegate = CustomFreeAim;
      }


      private float CustomGetAxis(string AxisName)
      {
        //get the axis from CNControls' joystick
        return CnInputManager.GetAxis(AxisName);
      }


      private Vector2 CustomFreeAim (bool cursorIsLocked)
      {
        //get the axis from CNControl's "FreeAim X" and "FreeAim Y" axes
        return new Vector2 (CnInputManager.GetAxis("FreeAim X"), CnInputManager.GetAxis("FreeAim Y"));
      }

    }
  • ok thank you , now the script compile whitout any error so i use cnjoystick prefab and asign this script to it , and then i do this steps:

    1- i add one joystick to left area for movement and
    A- on Mouse And Keyboard input its just moving the player in both editor and android.
    B- on Keyboard And Controller input , its the the same as A.
    C- on Touch Screen input its not working at all in both editor and android.

    then i

    2- add two joystick in the scene , one in left area for movement and another on the right area for camera control and
    A- on Mouse And Keyboard input both joystick just moving the player (but i think the right one should rotate the camera not moving the player?) and its happend on both editor and android.
    B- on Keyboard And Controller input , it's the same as A .
    C- on Touch Screen input , both joystick not working at all in editor and android.

    after this two step whit no luck i try to use two seprate scripts on two joystick , one for movement (original wiki script that now called ACInputCNControlsJoystick) and another for camera controll (this new script minus original wiki script lines , called ACInputCNControlsFreeAim) and strangely the result is exactly same as step 2.
    i need to mention that note , on Touch Scrren input method on both editor and android still touching on screen can rotate the camera but its controlled by AC not CNControls ( i know that because when i change ac free aim acceleration and speed Setting and Touch-Screen Setting its affected immediately on the scene).
    except Input method setting that changed on multiple steps all other setting is same as this screenshot:
      


    Setting_Screenshot
  • Thanks for the details.

    If you want to override the axes, you'll have to use either Mouse And Keyboard or Keyboard Or Controller.  Touch Screen input relies on internal input checks and can't be overridden in the same way.

    The free-aim delegate should only respond to the CNControls axis specified in the script - it is correctly mapped in CNControls, I take it?

    Now that you've separated the two scripts, what happens if you disable the Movement one and only have the Freeaiming one in the scene.  Does it still cause movement?  I would recommend leaving it like that for now while we fix the Freeaiming, and then re-enable it afterwards.  What are the settings of this second CNControls joystick?
  • edited October 2017
    OH ! :\">
    i forgot to insert inputs on CNControlls joystick so after I add FreeAim inputs on that everything now working just like what I want ( for anyone else that have same problem, I use two script method that I mention on last post) . so now based on your saying about override axes on Touch Screen input method , can I use Mouse And Keyboard input method on android device because so far I can see now and after some tests  everything work fine on android with this settings. can be any problem on this method on the future?
    and THANK YOU Chris .

  • It may bring about some UI issues, but if so let me know and we'll look into it.
  • I think you're best off using Touch Screen input if possible, actually - but currently you can't override the inputs as you've found.  I'll address that in the next release, with a new "First person movement" touch-screen option named "Custom Input", that'll be used solely for overriding input.
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.