Class ThirdPersonControl
- Namespace
- WitShells.ThirdPersonControl
Third-person character controller with customizable settings via ScriptableObject. Can receive input from ThirdPersonInput or be controlled directly via properties.
public class ThirdPersonControl : MonoBehaviour
- Inheritance
-
ThirdPersonControl
Fields
OnGroundedChanged
public UnityEvent<bool> OnGroundedChanged
Field Value
- UnityEvent<bool>
OnJump
public UnityEvent OnJump
Field Value
- UnityEvent
OnLand
public UnityEvent OnLand
Field Value
- UnityEvent
OnSpeedChanged
public UnityEvent<float> OnSpeedChanged
Field Value
- UnityEvent<float>
Properties
Animator
The Animator component (auto-cached from self or children).
public Animator Animator { get; }
Property Value
- Animator
CameraTarget
Camera target transform for movement direction reference.
public Transform CameraTarget { get; set; }
Property Value
- Transform
CharacterController
The CharacterController component (auto-cached).
public CharacterController CharacterController { get; }
Property Value
- CharacterController
Crouch
Crouch input state.
public bool Crouch { get; set; }
Property Value
CrouchSpeed
Gets the effective crouch speed from settings or override.
public float CrouchSpeed { get; }
Property Value
CurrentSpeed
Current movement speed.
public float CurrentSpeed { get; }
Property Value
Direction
Movement direction input (X = horizontal, Y = vertical).
public Vector2 Direction { get; set; }
Property Value
- Vector2
GroundCheckDistance
Gets the effective ground check distance from settings or override.
public float GroundCheckDistance { get; }
Property Value
GroundLayers
Gets the effective ground layers from settings or override.
public LayerMask GroundLayers { get; }
Property Value
- LayerMask
GroundedGravity
Gets the effective grounded gravity from settings or default.
public float GroundedGravity { get; }
Property Value
IsGrounded
Whether the character is currently grounded.
public bool IsGrounded { get; }
Property Value
Jump
Jump input. Set to true to trigger a jump.
public bool Jump { get; set; }
Property Value
JumpForce
Gets the effective jump force from settings or override.
public float JumpForce { get; }
Property Value
JumpTimeout
Gets the effective jump timeout from settings or default.
public float JumpTimeout { get; }
Property Value
RotationSmoothness
Gets the effective rotation smoothness from settings or override.
public float RotationSmoothness { get; }
Property Value
RunSpeed
Gets the effective run speed from settings or override.
public float RunSpeed { get; }
Property Value
Settings
The settings ScriptableObject. Can be changed at runtime.
public ThirdPersonSettings Settings { get; set; }
Property Value
Sprint
Sprint input state.
public bool Sprint { get; set; }
Property Value
TerminalVelocity
Gets the effective terminal velocity from settings or default.
public float TerminalVelocity { get; }
Property Value
VerticalVelocity
Current vertical velocity.
public float VerticalVelocity { get; }
Property Value
WalkSpeed
Gets the effective walk speed from settings or override.
public float WalkSpeed { get; }
Property Value
Methods
ApplySettings(ThirdPersonSettings)
Apply settings from a ThirdPersonSettings ScriptableObject.
public void ApplySettings(ThirdPersonSettings newSettings)
Parameters
newSettingsThirdPersonSettings
ForceJump()
Force a jump regardless of current state.
public void ForceJump()
ResetVerticalVelocity()
Reset vertical velocity (useful after teleporting).
public void ResetVerticalVelocity()
Teleport(Vector3)
Teleport the character to a position.
public void Teleport(Vector3 position)
Parameters
positionVector3
Teleport(Vector3, Quaternion)
Teleport the character to a position with rotation.
public void Teleport(Vector3 position, Quaternion rotation)
Parameters
positionVector3rotationQuaternion