GSoC Week 5: The Swing King
Last week involved a lot of discussions. The plan for the next two months is now a lot clearer. Here’s a quick fun video that should explain the title of this blog post.
What have I been upto?
WoodAndStoneCraftingJournal
With last week’s journal improvements, it was time to put the journal to some good use. A good technique to do this is to use the main Gamplay module for all story/lore related journal entries. However for most of the content related entries like crafting tutorials or cooking recipes, the best way to go is to create Journal extension modules. These extension modules would connect each content module to the Journal module. Essentially, the Journal extension module would house the Journal entries related to that content module which can easily be reused by multiple gameplay modules.
I went ahead and created the first Journal Extension module as a proof of concept with only about 8 entries to demonstrate how it would work. The WoodAndStoneCraftingJournal has a dependency on WoodCrafting, StoneCrafting and Journal. It contains the journal entries pertaining to both WoodCrafting and StoneCrafting (since both are a little related).
Where are the puzzles?
A major chunk of my last two month work consists of making Puzzles and adding them to my exploration centered gameplay module. After some discussion with flo about cata’s project on scenarios, I realised that it would be redundant to spend time working on mechanisms for action/event triggered changes. Since the Scenarios project would be focused on dealing with this, it would be a better idea that I aim towards making puzzle elements like traps, portals and other dangerous pieces.
Adventure Assets
With this new direction to work on, I’ve created a list of potential items that I could work on. Also a new module called AdventureAssets has been created to house such elements.
The idea now, is that I would create various puzzle elements and combine them together in a few different settings. I would create structure templates for these puzzles akin to the dungeons in GooeysQuests. This would allow me to place these puzzles in my exploration world manually by using a structure spawner. I plan to place these puzzles in the world manually and share the saved file which could be played with.
The Swinging Blade
The first item I decided to work on was the Swinging Blade. The setup consists of a huge blade that swings to and fro from one edge of the room to the other. This would serve as on obstacle and coming in contact with the blade would deal damage to the player.
I started working with a crude swinging blade model made by flo.
Animating the blade
I tried to make the blade move by linearly varying the pitch
(as in rotation’s yaw, pitch and roll
) of the entity. The GIF below shows this linear movement. This motion was later changed to an angular harmonic function, which factors in a time period (in seconds), an amplitude (in radians) and an offset/phase difference (in radians) which altogether looks like theta = Acos((2*pi/T)*t + phi)
.
Alignment and orientation
The swinging blade was misaligned and I wanted it to rotate in a direction purpendicular to it’s current rotation. Soon I realised that I had no control on the orientaion of the Swinging Blade entity that was being spawned by the Structure Template. I could choose the position but I couldn’t change the orientation and rotation. This is because the Structure Template module allows you to spawn the structure anywhere in the world, regardless of the orientation in which they were created. Meaning, a structure that faced North could be spawned in a manner that it now faces East. All contents of the structure should undergo a similar change in their orientation too. But the entities didn’t. Till now, it wasn’t a problem as the only things being spawned were the GooeysQuests’ skeletons. Their orientation didn’t matter as they were live entities that would come running after you for your life.
This PR adds the rotational control to spawning entities while using the SpawnPrefabsComponent
in the Structure Templates module.
New model and texture
Soon after I asked Quaternius to make a better model for the swinging blade and one thing led to another. Not before long, we had a full nice looking model ready with texture.
Inspiration
Model imported
Texture mapped
Final model imported
Making it hurt
I had a fine looking swinging blade, but it didn’t hurt yet. I could pass through it like silk.
Adding Colliders
First step was to make the entity a rigid body and add box shape colliders. Since the shape of the entity was not so simple, I had to create two different entities- one for the blade and one for the rod.
Adding the DoDamageEvent
Since the blade was the part which would hurt, a DamagePlayerComponent
was added to the blade to detect collisions with the player and trigger a DoDamageEvent
. However, simply sending a DoDamageEvent
would kill the player in no time as however small the damage being sent, being in contact with the blade even for a second would trigger the OnCollide
method several times to result in death.
Sending a CharacterImpulse
The solution to this was sending a CharacterImpulseEvent
to the player as well, in a direction outward from the blade. This sends the player to a relatively safer zone while also dealing some damage.
Multiplayer ready?
The swinging blade is not yet multiplayer ready. There are quite a few issues on dealing with the Swinging Blade in multiplayer. The movement prediction on the server side deals with the CharacterImpulseEvent
which makes the damaging systems function very differently even if there is a little lag. Often the player experiences too many impulses in a short time frame that end up killing him alone, even without the DoDamageEvent
being sent.
The PR which deals with the entire work on the swinging blade is here. It is still in progress with only the task of making it work in multiplayer remaining outstanding.
Up for next week should be more work on puzzles, a few more interesting traps and hopefully multiplayer fixes.