Move in Unity3D by Jason Weimann – Covering All the Basics

June 30, 2020

Fundamentals of Movement in Unity

All Basic Options

Move in Unity3D – Ultimate Unity Tutorial

Youtube – Link

By: Jason Weimann


Introduction

This video stuck out to me because it always takes me a bit of time to setup even basic movement at the beginning of a small Unity project because there are just so many different approaches that will result in movement, but I always want to try and figure out the optimal solution. Jason Weimann is a great source for covering Unity basics, so this new tutorial looked like a good way to really nail down all the different basic movement options in Unity and really get a strong understanding of when to use different types of movement for different projects and why.

Top Down Movement in Unity Tutorial

August 13, 2019

Unity Top Down Movement

Brackeys Tutorial

Youtube – TOP DOWN MOVEMENT in Unity!

By: Brackeys

This seemed to fit well with the Pokemon tutorials I was doing recently so I decided to give it a look. It’s been a while since I used Animator variables to control 2D animations so this was a nice refresher for that, but they also used Blend Trees which is something I had not seen before.

The initial script was very simple. This was a 2D Rigidbody setup, so it’s more physics based than the Pokemon tutorial I am doing. As usual for physics in Unity, they do the physics work in a FixedUpdate method, however, they still receive the input in a standard Update method. I always see you should do your physics in FixedUpdate to deal with frame rate variance, but had not seen anything specific about splitting up the input and physics into the two different Updates.

The Animator starts by adding two simple parameters: float Horizontal and float Vertical. The Blend Tree happens in a single state in the Animator for the Animator Controller for the player. When you right click and select “Create State”, you select “From New Blend Tree” instead of “Empty”. You can double click it to go one level deeper into this state node. It’s important to note the parameters apply here too, so they are useable throughout all the levels.

In this Blend Tree, there are three main factors to account for: the parameter, the thresholds, and the animations. You start with the parameter to check. You can then set “Motion Fields” which will hold an animation and parameter thresholds. It will then check the parameter relative to the thresholds set to determine which animation to play. This simple 2D walking animation set is a great example to show this off in a simple way, as it basically just switches between the 4 different directional walking animations depending on the combination of the horizontal and vertical parameters.

They then go back to the top level of the Animator to tie everything together. They make a transition from Idle to this Blend Tree, and vice a versa. This just makes sure to set a state for what to do when the player isn’t putting in any inputs.

Finally, to tie this new Animator setup in with the actual movement script and player input, they go back to the PlayerMovement script. The small addition needed here is simply setting the Animator parameters equal to the input gotten in the Update method.

Overall, this was a neat way to approach 2D movement in Unity a bit differently than I have before. The Animator blend tree definitely seems nice for keeping the PlayerMovement script cleaner and easier to read instead of cluttering it with a lot of input comparisons to determine different sprites and animations to use.

Experimenting with Unity: Player Movement – Rotation

August 1st, 2018

Experimenting with Unity: Player Movement

Player controlled by rotation about a point

Vimeo – Video of Rotational Movement

I was experimenting with controlling a player agent solely through rotational forces. The first style I looked at was not a force in the physical sense as it just operates on moving the player at a constant rotation speed. This is dictated by the placement of a rotation pivot which the player can place to indirectly move the player agent.

To add an extra amount of control, the player can also press a key in order to reverse the direction of the rotation (switch between clockwise and counterclockwise). This combination of features led to some interesting movement patterns. One of the first things that jumps out is the fact that the movement being dictated by a constant rotation speed still leads to varying velocities by the player agent as this will vary drastically with the radius between the pivot point and the player object. Large pivot distances can lead to dramatic speeds, but will lead to the player covering a larger area.

Notes to remember:

I was having an issue where the rotation was not perfectly making a circle in the game view. It turns out the scripts were correct, but the camera needed to be set to orthographic so the camera was just viewing it at an angle. Remember to check both the editor view and game view closely to help determine camera-based issues.

Using cursor inputs in Unity is a bit awkward. It has been done plenty of times so the basic scripting is available on Unity’s main site, but the process of creating a plane, raycasting, and converting between screen and world space is a lot to keep track of. This might also be something to look into if mouse inputs are acting strange.