Joystick Third Person Controller
I have a joystick that works well (third person controller) , he walks, looks around and moves forward , but he did not play the animations I did , since I have every movement of my player ready for the Playmaker , I just I modified the sample scene CN Controls Unit Assets to operate the joystick and put my character, but the animations do not work , I think is the script that is not working in my play animations
using UnityEngine;
using CnControls;
// This is merely an example, it's for an example purpose only
// Your game WILL require a custom controller scripts, there's just no generic character control systems,
// they at least depend on the animations
[RequireComponent(typeof(CharacterController))]
public class ThidPersonExampleController : MonoBehaviour
{
public float MovementSpeed = 10f;
private Transform _mainCameraTransform;
private Transform _transform;
private CharacterController _characterController;
private void OnEnable()
{
_mainCameraTransform = Camera.main.GetComponent<Transform>();
_characterController = GetComponent<CharacterController>();
_transform = GetComponent<Transform>();
}
public void Update()
{
// Just use CnInputManager. instead of Input. and you're good to go
var inputVector = new Vector3(CnInputManager.GetAxis("Horizontal"), CnInputManager.GetAxis("Vertical"));
Vector3 movementVector = Vector3.zero;
// If we have some input
if (inputVector.sqrMagnitude > 0.001f)
{
movementVector = _mainCameraTransform.TransformDirection(inputVector);
movementVector.y = 0f;
movementVector.Normalize();
_transform.forward = movementVector;
}
movementVector += Physics.gravity;
_characterController.Move(movementVector * Time.deltaTime);
}
}
Your answer
Follow this Question
Related Questions
How can I listen for input from all joystick axes through c sharp code? 0 Answers
Simple Third Person Controller and Animation Script 0 Answers
Problem trying to control Pac Man on Smartphone (basic version of Pac Man game made in Unity). 0 Answers
how to map joystick for mobile game? 0 Answers
Animation "pops back" to frame zero after leaving the animation controller state playing it? 1 Answer