All Projects → ZuBsPaCe → unity-smooth-movement-test

ZuBsPaCe / unity-smooth-movement-test

Licence: MIT license
Try and compare movement types in Unity

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to unity-smooth-movement-test

learn-unity-by-making-games
learn-unity-by-making-games
Stars: ✭ 32 (+45.45%)
Mutual labels:  unity-tutorial, unity2d
FyWorld
FyWorld - Base-Building / Simulation Game & Tutorial in Unity
Stars: ✭ 207 (+840.91%)
Mutual labels:  unity-tutorial, unity2d
UnityDebug
A wrapper script for Unity debug calls to use conditional attributes in order to avoid debug code being compiled into release builds.
Stars: ✭ 29 (+31.82%)
Mutual labels:  unity-tutorial, unity2d
template-unity-package
A Github template for creating a new Unity Package. Hit the green "User this template" next to "Clone or download" to get started!
Stars: ✭ 50 (+127.27%)
Mutual labels:  unity-tutorial, unity2d
Unitylibrary
📚 Library of all kind of scripts, snippets & shaders for Unity
Stars: ✭ 1,968 (+8845.45%)
Mutual labels:  unity-tutorial, unity2d
50-unity-tips
A collection of 50 tips for Unity (focusing on Mobile) ranging from editor tools to serialization to UI shortcuts.
Stars: ✭ 80 (+263.64%)
Mutual labels:  unity-tutorial, unity2d
Unity3D-Cars
A project built for a Renaissance Coders tutorial to introduce vehicle physics.
Stars: ✭ 60 (+172.73%)
Mutual labels:  unity-tutorial
unity-shooting-tutorial
「【Unity 入門】全方位シューティングを作る 全26回」の完成プロジェクト
Stars: ✭ 22 (+0%)
Mutual labels:  unity-tutorial
Webview-unity-3d-2017.3-or-higher-
Webview unity 3d 2017.3 or higher - can be open website url on unity3d or open Html5, html and js on unity offline
Stars: ✭ 18 (-18.18%)
Mutual labels:  unity-tutorial
Object-Pooling-for-Unity
Object Pooling for Unity
Stars: ✭ 118 (+436.36%)
Mutual labels:  unity2d
shellcore
Shellcore Command Remastered
Stars: ✭ 41 (+86.36%)
Mutual labels:  unity2d
LocalizationService
Tools for localization Unity's UIText components
Stars: ✭ 22 (+0%)
Mutual labels:  unity2d
Game-Assets-And-Resources
Free and paid game assets and game resources for 2D games, 3D games, mobile games, Steam games, Unity games, and other games.
Stars: ✭ 164 (+645.45%)
Mutual labels:  unity2d
UnityTetris
Tetris clone written in C# and using Unity engine to render.
Stars: ✭ 131 (+495.45%)
Mutual labels:  unity2d
awesome-unity
A curated list of awesome Unity games! 🎮
Stars: ✭ 346 (+1472.73%)
Mutual labels:  unity-tutorial
newbark-unity
🌳 A proof-of-concept Pokémon-style Retro RPG game framework created with Unity 🔥🌿💧⚡️
Stars: ✭ 139 (+531.82%)
Mutual labels:  unity2d
download.unity.com
Unity Download http://unity3d.com/unity/download/archive
Stars: ✭ 90 (+309.09%)
Mutual labels:  unity2d
Unity-FPS-Counter
#NVJOB FPS Counter and Graph. Free Unity Asset.
Stars: ✭ 44 (+100%)
Mutual labels:  unity2d
gocs
GameObject Component System for Unity
Stars: ✭ 102 (+363.64%)
Mutual labels:  unity2d
JimmysUnityUtilities
A bunch of code I like to have on hand while working in Unity
Stars: ✭ 93 (+322.73%)
Mutual labels:  unity2d

unity-smooth-movement-test

Try and compare movement types in Unity. The code is based on Unity 2018.4.7f1.

About

There are many ways to move a character in Unity. The Smooth Movement Test Application lets you play around with different settings. You can learn more about the different movement types in the blog entry.

Example of the smooth movement test application.

You can add multiple lanes with different parameters and compare the result.

Releases

WebGL Release (Runs in your browser)

Windows Release (Download, 18MB)

Linux Release (Download, 18MB)

Hint: The performance of the WebGL Release depends on your hardware and browser. If your running in performance issues, try a desktop release.

How to use

Add multiple lanes, set different lane settings and compare the results. Increase the ball count, enable the hinge joint option and try to find the settings which look best to you.

Move the mouse to the top center or bottom center of the canvas to move up or down. Alternatively use the Arrow Keys.

Press F to follow or unfollw the character. You can press the Arrow Keys while following to change the lane.

The Log option will print Update and FixedUpdate timings to the developer console in the browser, which can usually be opened with F12. Only enable this a short time, because a large log can slow down or even crash the browser. The desktop versions will create a log file instead called SmoothMovement.log.

Settings

Speed

Changes the target velocity of all characters, specified in Units per Second. All movement types which directly set the position or the velocity will use this exact value. The movement types AddForce, AddImpulse and AddVelocity will use a simple PID Controller which smoothly adjusts the current velocity according to deviation from the specified target velocity.

VSync

Enables or disables Vertical Sychronization of the renderer and the screen. If you enable VSync, the frame rate cannot be higher than the refresh rate of your screen. This reduces frame time variance leading to stuttering and screen tearing.

Frame Rate

By disabling VSync you will be able to set a target frame rate.

Lanes

Each lane can have different lane settings. That way you can compare the smoothness of the motion and the effect of the lane settings on the balls.

Balls

You can add some "Balls" to the simulation. Spheres with a Dynamic Rigidbody2D, which will collide with the character.

Hinge

Adds a HingeJoint2D component to the character with a white ball attached to it. The ball is a dynamic rigidbody with interpolation enabled. It circles around the player and is the only object affected by gravity. The hinge joint can affect the movement of the character.

Display

Sprite shows you the position of the character which the player will see in the game, possibly interpolated. Dragging the slider will display the rigidbody position, indicated by a red sqare. This is the current position of the character used by the physic engine.

Restart

Restarts the simulation with the same settings.

Log

This will output the information about the Update and FixedUpdate cycles. You can inspect their order and 3 values: 1) the real duration of the frame measured by System.Diagnostic.Stopwatch. 2) Time.deltaTime. 3) Time.time.

In the browser application you need to open the developer console to see the output (Press F12). In the standalone application a file will be written alongside the executable called "SmoothMovement.log".

Settings

You can specify settings per lane or all lanes can share the same settings. Shared settings are useful to measure the performance of the specified lane settings.

Follow

The camera will follow the character sprite with a yellow highlight. Press F to switch this setting on or off. You can jump through the lanes with the up and down arrow keys while following. The camera position is set in LateUpdate.

Reset

Resets all settings and restarts the simulation.

FPS

Shows the amount of Update cycles per Second, measured by a Stopwatch instance. The value is updated twice per second.

Variance

Shows (half) the difference between the smallest and longest Update cycle duration. The value is updated twice per second. A high variance value can lead to stuttering motion.

Method (Lane setting)

The movement type will either be applied in Update or FixedUpdate according to this setting. Unity advises us to use FixedUpdate for a stable physic simulation. FixedUpdate also enables the interpolation setting.

Body Type (Lane setting)

Switch between a kinematic or dynamic rigidbody used for the character. A dynamic rigidbody enables the usage of movement type AddForce and AddImpulse.

Movement (Lane setting)

Select the method used for moving the rigidbody of the character. The procedure is repeated in Update or FixedUpdate depending on the Method set above.

  • Transform.Position moves the character by setting transform.position directly.
  • Rigidbody.Position moves the character by setting Rigidbody2D.position directly.
  • Rigidbody.MovePosition moves the character by calling Rigidbody2D.MovePosition().
  • Rigidbody.SetVelocity moves the character by setting Rigidbody2D.velocity.
  • Rigidbody.AddVelocity moves the character by adjusting Rigidbody2D.velocity smoothly over time with a simple PID Controller.
  • Rigidbody.AddForce moves the character by calling Rigidbody2D.AddForce() with ForceMode2D.Force. The force is smoothly adjusted over time with a simple PID Controller.
  • Rigidbody.AddImpulse moves the character by calling Rigidbody2D.AddForce() with ForceMode2D.Impulse. The force is smoothly adjusted over time with a simple PID Controller.

Interpolation (Lane setting)

Method FixedUpdate enables you to assign an interpolation type to the character sprite.

  • None disabled interpolation. The sprite will always be at the rigidbody position.
  • Rigidbody Interpolate uses the standard Unity interpolation setting of Rigidbody2D.
  • Rigidbody Extrapolate uses the standard Unity extrapolation setting of Rigidbody2D.
  • Custom Bad uses a simple self made interpolation, which lerps the position of the sprite from the previous rigidbody position to the last calculated rigidbody position. The last calculated rigidbody position is incorrect, because it is determined in FixedUpdate itself, before the "internal physic update" of Unity.
  • Custom Good uses a simple self made interpolation, which lerps the position of the sprite from the previous rigidbody position to the last calculated rigidbody position. The last calculated rigidbody position is retrieved correctly after the "internal physic update" of Unity. The trick is to get the final rigidbody position in a Coroutine, which yields WaitForFixedUpdate().
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].