top of page
Search
  • Writer's pictureJack McPherson

Improvised Weapons In The Forgotten Forest.

The purpose of this blog post is to show the development of the improvised weapon system key to the forgotten forest. I'll be showing the ambition behind the feature, how I went about creating the feature along with how I plan to expand on it.


The Feature And what I want to achieve

The ambition behind the improvised weapons system was to expand on player agency within the core game loop of the forgotten forest.

The player explores the forest playing through multiple scenarios, does combat with multiple enemies. Finally returning to the hub space to prepare for their next bout of exploration and combat. The ambition of improvised weapons feature is to lend itself to the battle segment of the game loop and giving the player multiple options and a great deal of agency when dealing with their problems. The end goal is to create a feature that allows the player to react to their environment and use it to their advantage. If a player see's spears they should be able to pick up a spear, if they see a dead goblin and want to hit an enemy with it. I want to be able to facilitate that level of agency and not limit the players choices.





The feature


When designing the feature I had to decide whether it would be a separate manager controlling the weapon the player is holding. Or an embed the feature within the player. I decided to embed the feature within the player because the feature works in tandem with the players health, and the different states it can move into. If the player dies it makes sense that it wouldn't be able to throw or pick up any improvised weapons.



I created an empty game object inside of the players right hand which all the weapons the player can wield and throw are nested inside of it. This made it a lot easier to reference them in the player script for turning them on and off.



All these objects are then placed in the below arrays making it easy to reference them individually and using forloops I'm able to easily control the states of all of them.







Next up is creating the function that instantiates the thrown weapons so the player can pick up and throw weapons making them all versatile and disposable.


I wrote the below code to make it so at the apex of a throw animation I could use the following function to instantiate the correct throwable instance of a weapon and apply force in the direction of the players forward transform.


public void throwWeapon()

{

EqupiedWeapon = null;

Projectile = Instantiate(ThrownWeapon, throwPos.transform.position, throwPos.transform.rotation);

Projectile.GetComponent<Rigidbody>().AddForce(throwPos.transform.forward * 200);

for (int i = 0; i < Weapons.Count; i++)

{

if (Weapons[i].activeSelf == true)

{

Weapons[i].SetActive(false);

EqupiedWeapon = null;

ThrownWeapon = null;

}

}

}


After this and we've got find the point to activate this function. No better place than the follow through of the throw animation. One super effective way to activate a function during an animation is an animation event. The small blue tab at the top of the animation timeline is the keyframe in which the animation event is executed and it will execute the selected function. In this case being the throwWeapon() function written above!


The Thrown weapon is a prefab assigned to the throwable array. These objects can either have specific animation rotations during the throw, making the weapon spin. We can effect the mass of the rigid body of the throwable so when instantiated and with force is applied it travels further and faster.


Once we put it all together we get a nice pull back. We can add some UI to show the direction of the throw and then create the throw!


Once we have some enemies and throw together some cosmetic effects we can really show the effect of thrown projectiles and we have a really strong base to develop this feature further!





Expanding on improvised weapons


One of the key pillars of this game is really allowing player agency within combat. Developing this feature further I would like to create essentially a universal function that will either pick up a weapon or if the correct prompt appears to interact with parts of the environment. This could range from knocking over furniture, destroying parts of the environment and perhaps even using the environment to damage and possibly kill enemies. Next I'll be looking into UI to represent the improvised weapons and will make it so you can carry two to use at your leisure. switching between them with a simple button press.



Thanks for reading, I hope you've enjoyed what I've made so far. In the next blog post I'll be showcasing my development of the enemy behaviours in the game and the plans to make enemies with modular behaviours to make proto typing enemy types much easier.





Post: Blog2_Post
bottom of page