This is a list of the FIVE (plus one!) measures of distance that every #gamedev should know!

๐Ÿงต๐Ÿ‘‡

Starting from the most well-known one...

1โƒฃ EUCLIDEAN DISTANCE ๐Ÿ“

Measures the distance between two points, using the Pythagorean theorem.

In Unity: Vector3.Distance(A,B).
2โƒฃ VECTOR DISTANCE ๐Ÿ“

Is a vector that starts from ๐Ÿ…ฐ๏ธ and goes to ๐Ÿ…ฑ๏ธ.
It is pretty handy in LINEAR ALGEBRA, as it can avoid Trigonometry.

It has a DIRECTION, meaning that ๐Ÿ…ฐ๏ธ-๐Ÿ…ฑ๏ธ is not the same of ๐Ÿ…ฑ๏ธ-๐Ÿ…ฐ๏ธ!

In Unity, you can calculate it by simply subtracting the two vectors!
3โƒฃ COSINE DISTANCE ๐Ÿ’ก

It measures the alignment of two UNIT VECTORS, as the cosine of the angle between them:

๐Ÿ”น A โ€ข B = +1 โ†’ fully aligned
๐Ÿ”น A โ€ข B = 0 โ†’ orthogonal
๐Ÿ”น A โ€ข B = -1 โ†’ opposite direction

Also known as DOT PRODUCT, it is very useful for shaders!
3โƒฃbis: ORTHOGONAL PROJECTION

When the DOT PRODUCT is used on two vectors that are not UNIT VECTORS, it actually projects one onto another.

Below, you can see that A โ€ข B actually measures the ORTHOGONAL PROJECTION of A onto B.

In Unity: Vector3.Dot(A,B)
4โƒฃ MANHATTAN DISTANCE ๐Ÿ™๏ธ

Also known as TAXICAB DISTANCE, it measures the distance between two points when you cannot move diagonally. Pretty much like in a big city like Manhattan!

Both Euclidean & Manhattan are special cases of the MINKOWSKY DISTANCE.
5โƒฃ GREAT-CIRCLE DISTANCE ๐ŸŒ

The shortest distance between two points on the surface of a sphere.

You need to know:

๐Ÿ”นr: radius of the sphere
๐Ÿ”นฮป: longitude of both points
๐Ÿ”นฯ†: latitude of both points

For small enough distances, it converges to the Euclidean distance.
โœจ Thank you for reading! โœจ

If you are interested in #gamedev, shader coding, AI & ML, follow me for more content like this! ๐Ÿ˜Ž

I also have a @Patreon with hundreds of Unity tutorials! Feel free to have a look! โ˜บ๏ธ

patreon.com/AlanZucconi

โ€ข โ€ข โ€ข

Missing some Tweet in this thread? You can try to force a refresh
ใ€€

Keep Current with Alan Zucconi

Alan Zucconi Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @AlanZucconi

8 Mar
Let's talk about @unity3d, and the execution order of its event functionsโ€”such as ๐š‚๐š๐šŠ๐š›๐š and ๐š„๐š™๐š๐šŠ๐š๐šŽ.

Trust me when I say that ...IT'S WAY MORE COMPLICATED THAN YOU THINK. ๐Ÿ˜ฌ

#gamedev #unitytips #madewithunity

๐Ÿงต๐Ÿ‘‡
๐Ÿ”น๐—™๐—ถ๐—ฟ๐˜€๐˜ ๐—ฆ๐—ฐ๐—ฒ๐—ป๐—ฒ ๐—น๐—ผ๐—ฎ๐—ฑ

1โƒฃ ๐™ฐ๐š ๐šŠ๐š”๐šŽ: always called before any ๐š‚๐š๐šŠ๐š›๐š & after a prefab is instantiated

2โƒฃ ๐™พ๐š—๐™ด๐š—๐šŠ๐š‹๐š•๐šŽ: called just after a ๐™ถ๐šŠ๐š–๐šŽ๐™พ๐š‹๐š“๐šŽ๐šŒ๐š is enabled (including when loaded, created, or a ๐™ผ๐š˜๐š—๐š˜๐™ฑ๐šŽ๐š‘๐šŠ๐šŸ๐š’๐š˜๐šž๐š› script is added)
๐Ÿ”น๐—•๐—ฒ๐—ณ๐—ผ๐—ฟ๐—ฒ ๐˜๐—ต๐—ฒ ๐—ณ๐—ถ๐—ฟ๐˜€๐˜ ๐—ณ๐—ฟ๐—ฎ๐—บ๐—ฒ ๐˜‚๐—ฝ๐—ฑ๐—ฎ๐˜๐—ฒ

3โƒฃ ๐š‚๐š๐šŠ๐š›๐š: called before the first frame update. This happens only if the script is enabled. ๐š‚๐š๐šŠ๐š›๐š can also be made into a coroutine by changing its return type to ๐™ธ๐™ด๐š—๐šž๐š–๐šŽ๐š›๐šŠ๐š๐š˜๐š›
Read 13 tweets
22 Feb
Let's talk about NEURAL NETWORKS. ๐Ÿง 

Most of you are probably familiar with them. ๐Ÿง‘โ€๐Ÿ’ป

But not many know HOW they actually work andโ€”even more importantlyโ€”WHY they work. ๐Ÿ”ง

So, let's take a journey to understand what makes Neural Networks so effective... ๐Ÿ“Š

#ML #AI #NN

๐Ÿงต๐Ÿ‘‡
Let's start with a simple question...

โ“ What problem are NNs trying to solve? ๐Ÿค”

Generally speaking, NNs are trained on examples, to produce predictions based on some input values.

The example data (input + desired output) draws a curve that the NN is trying to fit.
In a nutshell, NNs areโ€”like most ML toolsโ€”a fancy way to fit the curves inherently generated by the examples used to train it.

The more inputs it needs, and the more outputs it produces, the higher the dimension of the curve.

The simplest curve we can fit is ...a line! ๐Ÿ˜…
Read 21 tweets
10 Feb
This is a list of TEN (plus one) games that are "accidentally" TURING COMPLETE. ๐Ÿ–ฅ๏ธ

In a nutshell, when a game is Turing Complete you can use it to build a WORKING COMPUTER. ๐Ÿคฏ

If you are a parent: please don't underestimate games as a creative medium.

Let's start with...

๐Ÿงต๐Ÿ‘‡ ImageImageImage
1โƒฃ Minecraft โ›๏ธ

Unsurprisingly, @Minecraft is indeed Turing Complete. ๐Ÿ–ฅ๏ธ

This is possible thanks to the so-called REDSTONE CIRCUITS, which allow to build simple logic gates. ๐ŸŸฅ

And if you are really, REALLY committed ...you can even build a computer!

2โƒฃ Portal 2 ๐ŸŸ ๐Ÿ”ต

Yes. Everybody's favourite game is Turing Complete! ๐Ÿฅฐ

@anklejbiter used Portal 2 level editor to create a 3-Digit Binary Calculator. De-facto proving it can be used for arbitrary computation.

steamcommunity.com/sharedfiles/fiโ€ฆ
Read 14 tweets
2 Feb
After using @unity3d for almost 10 years, I want to share the TEN small features that are really helping me develop games faster.

Starting with my favourite... ๐Ÿ˜Ž

1โƒฃ Inspector Maths

You can write ACTUAL mathematical expressions in the inspector! ๐Ÿคฏ

Check the other ones!

๐Ÿงต๐Ÿ‘‡
2โƒฃ Animation Curves

Unity supports a super easy way to create smooth paths through ANIMATION CURVES. Perfect for blending & animating properties.

Creation:
public AnimationCurve Curve;

Usage:
float x = Curve.Evaluate(t);

#unitytips

docs.unity3d.com/ScriptReferencโ€ฆ
3โƒฃ Gradients

The equivalent of AnimationCurve for colours is Gradient. You can use it to create and sample smooth gradients.

Creation:
public Gradient Gradient;

Usage:
Color c = Gradient.Evaluate(t);

#unitytips

docs.unity3d.com/ScriptReferencโ€ฆ
Read 10 tweets
25 Jan
These are FIVE TRICKS that my colleagues and I have learnt from one academic year or REMOTE TEACHING in HIGHER EDUCATION. ๐Ÿ“š๐ŸŽ“

Every class is different, and every lecture has their own teaching style. But feel free to share this thread if you think it might help someone!

๐Ÿงต๐Ÿ‘‡
1โƒฃ ๐—ฆ๐—ฒ๐˜๐˜‚๐—ฝ ๐Ÿ–ฅ๏ธ

If you are using PowerPoint with a second monitor, you can actually resize the "Presenter View" window:

1โƒฃ๐Ÿ–ฅ๏ธ
๐Ÿ”ดShared screen with slides

2โƒฃ๐Ÿ–ฅ๏ธ
๐Ÿ”ตPresenter view with notes
๐ŸŸขMS Teams chat

So you can share your screen, see your notes & read questions!
2โƒฃ ๐—–๐—น๐—ฎ๐—ฝ๐—ฝ๐—ถ๐—ป๐—ด ๐—ผ๐—ป ๐— ๐—ฆ ๐—ง๐—ฒ๐—ฎ๐—บ๐˜€ ๐Ÿ‘

Every time a student present their work in front of the class, I invite everyone to clap. ๐Ÿ‘

A remote alternative is to encourage students to raise and lower their hands on MS Teams quickly.
Read 7 tweets
23 Jan
BEHAVIOUR TREES are the cornerstone of ARTIFICIAL INTELLIGENCE for #gamedev.

But they can be difficult to "grow". ๐ŸŒฑ

I have selected FIVE rather approachable papers that use EVOLUTION to grow behaviour trees AUTOMATICALLY, so you don't have to. ๐ŸŒฒ

Let's start with...๐Ÿ“

๐Ÿงต๐Ÿ‘‡ ImageImage
1โƒฃ "Evolving Behaviour Trees for the Commercial Game DEFCON" (2010)

๐Ÿ”นChong-U Lim
๐Ÿ”นRobin Baumgarten
๐Ÿ”นSimon Colton

researchgate.net/publication/22โ€ฆ ImageImage
2โƒฃ "Learning of Behavior Trees for Autonomous Agents" (2015)

๐Ÿ”นMichele Colledanchise
๐Ÿ”นRamviyas Parasuraman
๐Ÿ”นPetter ร–gren

arxiv.org/abs/1504.05811 ImageImage
Read 8 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!