Skip to content

Unity package containing a simple yet powerful priority based velocity controller

Notifications You must be signed in to change notification settings

Umbrason/VelocityController

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Velocity-Controller

Velocity Controllers allow for complex behaviour to arise from blending 'Velocity Overrides'. Velocity Overrides can be animated over their lifetime and chained together using the onComplete callback.

Examples

Simple 3D character controller:

[SerializeField] private VelocityController vc;
[SerializeField] private float jumpVelocity = 15f;

[...]
void FixedUpdate() {
  var movementInput = new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical"));
  movementInput = Quaternion.Euler(0, Camera.main.transform.eulerAngles.y, 0) * movementInput; //rotate input to convert to camera local
  vc.AddOverwriteMovement(new(movementInput, speed, VelocityBlendMode.Overwrite, VelocityChannelMask.XZ), 0f, 0); //Only affects the XZ plane
  vc.AddOverwriteMovement(new(Vector3.up, jumpVelocity, VelocityBlendMode.Overwrite, VelocityChannelMask.Y), 0f, 0); //Only affects the Y axis
}

Wind effect:

[SerializeField] private VelocityController vc;
[SerializeField] private float windStrength = 15f;
[SerializeField] private Vector3 windDirection = Vector3.right;

void FixedUpdate() {
  vc.AddOverwriteMovement(new(windDirection, windStrength, VelocityBlendMode.Additive, VelocityChannelMask.XYZ), 0f, 0);
}

About

Unity package containing a simple yet powerful priority based velocity controller

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages