Skip to content

About

No description, website, or topics provided.

Resources

Stars

3 stars

Watchers

2 watching

Forks

Latest commit

 

History

18 Commits

Folders and files

Repository files navigation

Third-Person-Controller VERSION:alpha 0.2

DO NOT USE IN COMERCIAL PROJECTS without permisions

Third-Person-Controller is rigidbody character controller with statemachine based logic and custom Dependency Injection

Supported state machines
Code State Machine ✔️
Visual scripting state machine ✔️

Current States
Idle ✔️
Walk ✔️
Run ✔️
Sprint ✔️
Jump ✔️
Crouch ✔️
Prone ✔️
In Air ✔️
Example: Creating custom Feature for state Using Code
using ThirdPersonController.Core.DI;
using ThirdPersonController.Core;
using UnityEngine;

public class ExampleFeature : BaseFeature
{
    [SerializeField] private float gravityValue = -10;
    
    private Rigidbody _rigidbody;
    
    public override void CacheReferences(IStateMachineVariables variables, IReferenceResolver resolver)
    {
      _rigidbody = resolver.GetComponent<Rigidbody>();
    }

    public override void OnEnterState() => Debug.Log("OnEnterState");

    public override void OnUpdateState() => Debug.Log("OnUpdateState");

    public override void OnFixedUpdateState() => _rigidbody.AddForce(Vector3.up * gravityValue, ForceMode.VelocityChange);

    public override void OnExitState() => Debug.Log("OnExitState");
}
Example: Creating custom Feature for state Using Visual Scripting
Here is still used code, but it's possible to do same using Visual Scripting, but not recomended

Example: Creating custom Transition Using Code
using System;
using ThirdPersonController.Core.DI;
using ThirdPersonController.Core.CodeStateMachine;

public class GroundedStateTransition : BaseStateTransition
{
    public bool shouldBeGrounded;
    
    private IMoveStateMachineVariables _variables;
    public override void Initialise(IStateMachineVariables variables,IReferenceResolver resolver)
    {
        _variables = variables as IMoveStateMachineVariables;
    }

    public override bool couldHaveTransition => _variables.IsGrounded == shouldBeGrounded;
}
Example: Creating custom Transition Using Visual Scripting


Screenshots


Known issues:
FootStep Feature lagging and code refactor

About

No description, website, or topics provided.

Resources

Stars

3 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages