About This Project
Project Ixola is a personal project made in Unity. This technical showcase took five weeks to develop, and an additional five weeks to refine mechanics.
About This Project
Project Ixola is a personal project made in Unity. This technical showcase took five weeks to develop, and an additional five weeks to refine mechanics.
The player can throw items they are grabbing. When the player throws the item down, the player is launched into the air.
In this snippet of code, ThrowDirectional(), when the player presses the X Key while grabbing something, the player throws whatever they are holding. The grabbed object's parameters are set to respond to physics and is thrown in a direction based on what direction the player is holding.
When the player throws an object downwards, the player will be launched upwards.
Grabbing certain objects keeps the player suspended in air. If the player throws in a direction, they will be launched accordingly.
This section of the Grab() function relies on Unity layer mask system. After checking if the object can be held via its layer, "Grabbing", it checks if the object has the "Hanging" layer. This sets the player to a position relative to the object that they are hanging on.
Then, the player's x,y,and z coordinates are frozen, leaving them in the air. Depending on the direction that the player grabs the object, their sprite will stay facing the direction of the object. isHanging prevents the player from incorrectly flipping the player's sprite while hanging on an object.
Different items do different things when thrown. There are only two items right now, a box and a wind box.
In the Update function, there is an if statement that checks for if the player is holding something. If so, the "wasThrown" condition will be set to true. If not, then a timer, "ThrowTimer" counts for 1 second before setting "wasThrown" to false. This is used to activate the thrown item's effect and is checked on every frame.
In response to the previous code, this function executes when the item collides with any other GameObject with a tag of "Ground" and has been thrown.
CreateEffect is a method called by the previous code. This method contains all of the code necessary to spawn the windbox, remove the item spawning it, and respawning the item. ThrowTimer is a simple method that waits one second before setting "wasThrown" to false.
When the player walks into these, they are blown in the wind's direction.
Like the last code snippet, these variables are necessary for the player to get pushed by the windbox. The "windSpeed" determines which way the player will get pushed, and the 2D Vector, "windDirection," pushes the player in the direction of the vector.
OnTriggerStay2D is a variant of the OntriggerStay function. When an object with a collider enters the area and stays in it, the function will execute until the object leaves the area. Here, when either the player or GameObject tagged as "Object," the "windDirection" and "windSpeed" are multiplied together and are incrementally added towards the player's velocity.
Tile Map
Pixel Fantasy Caves - Sdazi Art
Music
16-Bit Starter Pack — Music composed by Bert Cole, bitbybitsound.com
Sound Effects
Ultimate UI SFX Pack — JDSherbert
jsfxr (JavaScript Port of sfxr by DrPetter) — Eric Fredricksen