Touch Third Person Character Controller in Unity 2018 🎓 - YouTube
Joystick Problem.
After all the adjustments,
This error comes out.
…
NullReferenceException: Object reference not set to an instance of an object
ThirdPersonInput.Update () (at Assets/ThirdPersonInput.cs:34)
…
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.h = LeftJoystick.input.x;
Control.v = LeftJoystick.input.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);
}
}
Set the camera tag is ‘main camera’ in the right inspector of camera. It is solved.