Selasa, 21 Februari 2017

Moving Sprite

In Scratch, the script to set Sprite position at X=0 and Y=0 at the start of the program and then move the Sprite continuously to the right is as following:


The same thing can be done in Unity with the following script:


Below is a more detailed comparison between move related command in Scatch and the command in Unity.

Go To Certain Position

In Scratch:


It means go to position X=10 and Y=20.


In Unity:
It means go to position X=0.1 and Y=0.2

Note the writing of decimal number in Unity. The number 0.1 needs to be written as 0.1f and the number 0.2 needs to be written as 0.2f.

For integer number such as 0 there is no need to put f symbol afterwards.

Move Right

In Scratch


It means change the X position by 10 point.

In Unity
It means change the X position by 0.1 point.

Note that in Unity the 0.1 number is chosen instead of 10 because if the number 10 is chosen the Sprite movement will be way too fast and the Sprite will disappear from the screen very quickly.

Move Left

In Scratch


In Unity


Move Up

In Scratch


In Unity



Move Down

In Scratch


In Unity






Tidak ada komentar:

Posting Komentar