Unity 5: 2D Platformer-Player Controls [3.1]

Опубликовано: 16 Октябрь 2024
на канале: Dual Core Studio
2,327
55

UNITY 5: 2D Platformer-Player Controls [3.1]

In this episode we will create our first script and learn how to move our player.

DETAILED EXPLANATION:

Input.GetAxisRaw(): Returns -1,0 or 1
1-for positive button
-1-for negative button


Difference between GetAxisRaw() and GetAxis():

GetAxis()- also returns -1,0,1 but transition form one value to another is more smoothly
GetAxisRaw()- instant transition(good for platformer games)

Vector2(x-axis , y-axis)

With our Vector2(horizontal*speed , rB....) we multiply our speed(which we choose) with Input.GetAxisRaw(). In other words speed is multiplied by 1 or -1 or 0. When we press negative button, we multiply with -1 and we move to the left on x-axis and so on...

When working with Rigidbody2D, use FIXED UPDATE

:)

● Twitter:   / dualcorestudio  
● Instagram:   / dualcorestudio  
● Facebook:   / dualcorestudio  
--------------------------------------------------------------------------------------------
Official Website:
► https://www.dualcorestudio.com/
--------------------------------------------------------------------------------------------
Discord Crew:
❤️️   / discord