top of page

#MIXEDREALITIES

SCRIPTING WITH UNITY

Introduction to the experiment

For this week I decided to challenge myself with learning how to script in Unity. I worked through the tutorial provided by Prasanth to animate a basic spider. This spider was downloaded from the Unity store and it came with pre-made animations. This task raised some troubles, however with the help of Unity forums I was able to make the animations work.

Reasons for selection

Over the last couple of weeks I have slowly been progressing with using Unity. I now feel very comfortable navigating around Unity, creating basic scenes and adding basic physics to solid bodies. While these are very good skills to have mastered they prove to be very limited in terms of creating a game or a VR/AR experience. This is where scripting has come in handy, it has enabled me to add responsive features to the characters that are in the scene. Moreover, I really enjoy coding and I wanted to learn C# (which is the language used for Unity scripting).

Creating the basic animations

To create the basic animation, I first downloaded an animated spider from the Unity asset store. This came with pre-made animations that could be activated and controlled through the animator page and scripting. I first wrote a basic script that controlled the "Jump" and "Walking" animations for the spider.

Activating the walk and jump animations

Animator page as the walk and jump animation were activated

Adding the attack feature

The spider also came with an attack feature that wasn't added in the tutorial. I wanted to test my coding skills and add this animation to the spider. I wanted this animation to be activated using the "a" key so I followed the logic used for the jump and walk animation to complete the script.

Final script

Displaying the attack feature

Discussion

As previously discussed, most of the power in Unity is controlled by scripting. Therefore, it is vital I get to grips with the coding language and understand how to script basic scenes. These skills are important to create realistic VR/AR games as scripting allows for real time movement in the game that mimics the motion of the person playing the game. This will help the player believe the "VR" world is in fact the real one, thus helping to increase the presence of the game.

References

Prsanth's tutorial:

PSK. (2020, August 26). DES241 Animation Controller and Scripting #3 [Video file]. Retrieved from https://www.youtube.com/watch?v=_KYyQYgih_M.

bottom of page