UnityScripterAI
Discord ↗
Link Copied to Clipboard
×
"third person action adventure character controller where you can add custom actions"
```csharp using System.Collections; using System.Collections.Generic; using UnityEngine; public class ThirdPersonCharacterController : MonoBehaviour { public float speed; public float rotationSpeed; private Animator animator; private Rigidbody rb; void Start() { animator = GetComponent<Animator>(); rb = GetComponent<Rigidbody>(); } void Update() { float translation = Input.GetAxis("Vertical") * speed; float rotation = Input.GetAxis("Horizontal") * rotationSpeed; translation *= Time.deltaTime; rotation *= Time.deltaTime; transform.Translate(0, 0, translation); transform.Rotate(0, rotation, 0); if(Input.GetKeyDown(KeyCode.Space)) { animator.SetTrigger("isJumping"); } if(translation != 0) { animator.SetBool("isRunning", true); animator.SetBool("isIdle", false); } else { animator.SetBool("isRunning", false); animator.SetBool("isIdle", true); } } // Custom action method public void PerformCustomAction(string actionName) { animator.SetTrigger(actionName); } } ``` This script creates a basic third person character controller. You can add custom actions by calling the `PerformCustomAction` method and passing the name of the trigger in the animator controller.