What Is Scripting
Many Games are now using scripting languages
to do high level game code. Using scripts to do high level game code or game
code for that matter is an excellent way to increase productivity because
scripts do not need to be compiled. This means that the coder does not need to
wait for the game to compile before testing his latest changes and compilation
can take a long to do depending on the size of the project.
Now what is scripting in games? Scripting is when a text file
that contains information which is interpreted and then influences the game in
some way. Scripts can influence the game to create entities, give properties, and
define functions, classes and much more. One of the best examples of a game
engine that relies heavily on scripts would be Unity. In Unity every object can
have a script attached to it to influence its properties and behaviours. Below
is a script that I made for one of my unity games for another class, I would
like to show it as an example.
using UnityEngine;
using System.Collections;
public class Death :
MonoBehaviour
{//When The Player Hits this
it will send the player to its last checkpoint saved
public Transform Player;
void Start () {/*nothing*/}
// Update is called once per frame
void Update () {/*nothing*/}
void OnTriggerEnter(Collider other)
{
if (other.tag == "Player")
{// if player hit this send him back
to the last checkpoint
Player.GetComponent<ThirdPersonController>().GotoChechpoint();
}
}
}
What we can notice from this simple script (all it does is
moves the players position to the last saved Checkpoint) is that the scripts
have functions that are exposed from the game engine, GetComponent being one of
them. Also that functions define in another class defined in another script can
be called within this script. These interactions between scripts are easy to do
and act similar to how code would normally be done but with the advantage of
being quick to make and no compilation time.
I would highly recommend having some sort of scripting in any
game project. Below is a link to the game that uses this script, it’s called
Hover Tank which is extremely difficult and a link to the Unity home page.
Hover Tank:
Hover Tank:
Unity Home
Page:
No comments:
Post a Comment