092 - Firing a Bow (Part 1/4)

November 8, 2020

This week I worked on the Bowman skill that allows players to use a bow and arrow for ranged attacks.

I mentioned in 091 that I was not expecting to finish the Bowman prototype this week because I knew that there are some larger one-off implementations that were needed.

So this week I'll talk about some of the work that has gone into setting that foundation, and then next week I'll have a video of a player firing a bow.

Rendering Equipment

It is now possible to see equipment that is being held, such as a bow in a players hand.

As part of my work on the Bowman skill I implemented being able to see equipped items.

This is powered by a new addition to the engine that I am calling Named Points.

A Named Point is a point in model space that can optionally be influenced by an armature's bones.

A renderable can have any number of Named Points. Right now the RenderableId::Human's corresponding render descriptor contains two Named Points, MainHand and OffHand.

When rendering equipped weapons the RenderSystem looks up the appropriate Named Point along with the corresponding dual quaternions for the bones that influence that point and uses them to calculate the transformation matrix to apply to the equipment.

After taking some time to figure out the data structures and a clean implementation I am now happy with how things are set up.

The system should work well for future mount points that I need for different scenarios such as describing where to display particle effects or for specifying inverse kinematic targets.

Coordinated Sequence System

This week I implemented the concept of a CoordinatedSequence.

A CoordinatedSequence is used to describe a series of things that should happen.

A CoordinatedSequence can have one or more tracks that are driven simultaneously, each containing one or more steps that describe what should happen.

Here's a list of the steps for the sequence triggered by firing a bow, with the ones that I implemented this week marked as (SUPPORTED) and the work remaining for next week marked as (TODO).

  1. (SUPPORTED) Receive indication that a bow was fired

  2. (SUPPORTED) Trigger fire bow animation on human armature

  3. (SUPPORTED) Wait for pose marker for reaching towards back (quiver)

  4. (SUPPORTED) Spawn an arrow in the main hand

  5. (SUPPORTED) Wait until pose marker for touching bow

  6. (TODO) Trigger animation for bow's string pulling back and recoiling forwards

  7. (SUPPORTED) Wait for pose marker for releasing bow

  8. (TODO) Start spawned arrow mesh on a trajectory towards the target

  9. (TODO) Update the arrow's position every frame as we interpolate the trajectory

  10. (TODO) End sequence when arrow hits target

So there are a few more things to implement to be able to see a player fire a bow. I'll have them working by the next journal entry.

All of this is being implemented in a re-usable way so that future sequences will be easier to add in.

Other Notes / Progress

  • Continued familiarizing myself with WebGPU.

  • Broke out an enum ItemId from variants inside of IconName. Icons and items were previously stuffed into one enum. One of a handful of poor decisions that I made when I was first learning Rust back in 2018.

  • Created a crates/recipes in the engine to generically power crafting systems. The recipes system still needs a fair bit of work to begin to crystallize, but I'm making progress.

  • Came up with a 6 day per week training regiment for improving my art skills. Let's see how it goes.

Next Journal Entry

By the next journal entry I will have a prototype of the Bowman skill live.

If I get that in place early I will continue to work on the recipes system since it in an important foundation that will power several skills in the game.

Cya next time!