-
-
Save ditzel/3933efad282d739b5827cf1928fdcfb6 to your computer and use it in GitHub Desktop.
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using UnityStandardAssets.Characters.ThirdPerson; | |
public class ThirdPersonInput : MonoBehaviour | |
{ | |
public FixedJoystick LeftJoystick; | |
public FixedButton Button; | |
public FixedTouchField TouchField; | |
protected ThirdPersonUserControl Control; | |
protected float CameraAngle; | |
protected float CameraAngleSpeed = 0.2f; | |
// Use this for initialization | |
void Start() | |
{ | |
Control = GetComponent<ThirdPersonUserControl>(); | |
} | |
// Update is called once per frame | |
void Update() | |
{ | |
Control.m_Jump = Button.Pressed; | |
Control.Hinput = LeftJoystick.inputVector.x; | |
Control.Vinput = LeftJoystick.inputVector.y; | |
CameraAngle += TouchField.TouchDist.x * CameraAngleSpeed; | |
Camera.main.transform.position = transform.position + Quaternion.AngleAxis(CameraAngle, Vector3.up) * new Vector3(0, 3, 4); | |
Camera.main.transform.rotation = Quaternion.LookRotation(transform.position + Vector3.up * 2f - Camera.main.transform.position, Vector3.up); | |
} | |
} |
inputvector for left joystick isnt getting recognised
inputvector for left joystick isnt getting recognised
Yes, I am also facing this problem
The name in the joystick file was changed to just input, I had trouble finding it. Look around line 41 in the joystick file.
inputvector for left joystick isnt getting recognised
yes exactly i am also facing this problem when u go to this script u will see there is nothing inside it
Do it like this. Control.Hinput = LeftJoystick.Horizontal; not inputVector.x Control.Vinput = LeftJoystick.Vertical; not inputVector.y. Bcos d input is locked in d script.
NullReferenceException: Object reference not set to an instance of an object. thirdpersoninput.Update () (at Assets/thirdpersoninput.cs:30). Problem at the line of:
CameraAngle += TouchField.TouchDist.x * CameraAngleSpeed;
Camera.main.transform.position = transform.position + Quaternion.AngleAxis(CameraAngle, Vector3.up) * new Vector3(0, 3, 4);
Camera.main.transform.rotation = Quaternion.LookRotation(transform.position + Vector3.up * 2f - Camera.main.transform.position, Vector3.up);
The touch field has no reponse when play and how to fix this?
FixedJoystick and FixedButton script are deleted , please available that script ,
I can't use your asset
Assets\Scripts\ThirdPersonInput.cs(28,39): error CS1061: 'FixedJoystick' does not contain a definition for 'inputVector' and no accessible extension method 'inputVector' accepting a first argument of type 'FixedJoystick' could be found (are you missing a using directive or an assembly reference?)
: (
ThirdPersonInput is misspelled.