Skip to content

krthush/2d-unity-movement

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

2d Unity Movement

Unity project focused on building a solid foundation for 2d movement (video demo) - feel free to use it!

Last tested version of Unity: 2020.1.13.f1

Features:

✅ No rigidbodies / No 2d physics (allows for tight controls)
✅ Horizontal and vertical collisions
✅ Ascend and descend slopes (constant speed)
✅ Variable jump height
✅ Wall jumps
✅ Wall sliding
✅ Wall grab
✅ Slide down steep slopes
✅ Jump through platforms
✅ Moving platforms (moves passengers as well)

Controls:

Movement:
A/D: Left/Right movement
W: Jump

In air:
S: Fast Fall

On wall (facing left):
W: Wall jump
A+W: Wall jump climb
D+W: Wall leap off
Opposite controls for facing right

Project Usage:

N.B. You need to enable "Auto Sync Transformations" under the Physics 2D Project Settings.

Here's a quick run down of the important scripts/variables:

Scripts:

Adjustable Variables:

  • PlayerVelocity allows you to adjust:
    • Move speed (Left/Right movement)
    • Jump heights and time to reach jump height (calculates jump speed / gravity)
    • Acceleration time on ground and in air (calculates drag on ground and in air)
    • Fast fall speed
    • Wall jump, jump climb and leap off velocities
    • Wall slide speed
    • Wall stick time
  • Movement allows you to adjust:
    • Collision mask - what layers the object should collide with
    • Skin width - small tolerance given to collision detection
    • Distance between rays - smaller givens better detection but more computation
  • MovingPlatform allows you to adjust:
    • Waypoints to travel through
    • Platform's travel speed
    • Cycle through waypoints or not
    • Wait time at waypoints
    • Easing
  • PassengerMover allows you to adjust:
    • Passenger mask - what layer objects should be moved
    • Collision mask, Skin width and Distance between rays

Layers/Tags:

  • Through tag should be applied to platforms that can be jumped through
  • Player/Enemies/Allies layers can be used to allow collision or not as you wish
  • If Player/Enemy/Ally tag used, then object requires Movement to be able to detect collision and move correctly.

This was original made by following a Sebastian Lague video series, but has been heavily adapted to be tighter/smoother. If you'd like to start from scratch or don't understand components of the project I'd suggest using the videos as a guide!

Please feel free to post any issues or submit any pull requests and I'll get on em asap :)

About

Unity project focused on building solid foundation for 2d movement.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages