Scripting Experiment – Looking At Perspective Shifting Mechanics

In Balance our games central mechanic is the player can shift between the 2.5D and 2D perspectives to navigate the terrain. Being interested in how this mechanic was achieved for a while, and wanting to experiment with my own scripting ability, I decided to try coming up with my own concept of how this could be achieved.

My script is based around the idea of a raycast that goes across the Z axis slightly below the player to determine where they should land. This would mean the player would always land on whatever object was the heightist and also the closest to the camera that works perfectly for this mechanic.

As predicted the script worked to a basic level but there were some issues when jumping up into objects from below and moving sideways into one, however these are problems that could be solved with future iterations if I decide to continue for now I am happy knowing the core idea works as intended.

Different Gameplay Styles

A happy accident that emerged from a quick attempt to solve the above mentioned issues were two versions of the script, one that used multiple raycast with a for loop system and another which used a single raycast which led to two scripts that, while similar in code, were drastically different in gameplay style implications that were fun to analyse.

Player 1 – Single Raycast Script

The Player 1 script has a single raycast just below the player on the Y axis that is constantly checking across the Z axis for any object with the “Ground” tag, if it comes back as true it will set the players Z position to the raycast point of contact’s Z position.

This means it only updates when it is grounded in the 2D perspective and will not change while in the air or falling.

LorcansPerspectiveScript_Player1

In the digram the player jumps between point A and B and changes to 3D mode between the 2nd and 3rd images, however because this script only updates when it touches the ground it still reaches point B

Player 2 – Iterative Raycast With For Loop Script

The Player 2 script uses a for loop to check across the Z axis below the player while iterating down the Y axis until it comes back true, when it does it sets the players Z position to the point of contact’s Z position.

This means this script is always updating even while in the air and positions the player to whatever object is below it from the 2D perspective.

LorcansPerspectiveScript_Player2

In the digram the player jumps between point A and B, however because they change to 3D mode between the 2nd and 3rd image they land on plane C because the script was still checking what object was below mid jump

Advertisements
Scripting Experiment – Looking At Perspective Shifting Mechanics

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s