Posted May 25, 2022 by Forbidden Folds
#3D #3D Platformer #Cute #Funny #magnetism #Physics #Singleplayer #whalien
In this final entry of our core ability series, we will cover our WhaliumComponent. Every object in WHALIEN can be made influenceable by Ernest’s “magnetic” abilities through adding a WhaliumComponent to it.
The thought behind the component was to unify how we manage actors that we want to be influenced by Ernest’s abilities. We chose to implement this with an ActorComponent instead of a base actor, because the component approach made more sense considering the wide range of possible objects or parts that we wanted to be influenceable.
Take for example an actor that should have two individually influenceable parts: The basic WhaliumActor class would only be able to accomodate a singular influenceable part, so we would need to create a separate DoubleWhaliumActor or fiddle around with ChildActorComponents (which is never fun). In the component-based approach, we can simply add one WhaliumComponent for each influenceable part and everything is easy-going.
At its core our WhaliumComponent is an ActorComponent that modifies the attributes of a specified PrimitiveComponent, so that it works with our abilities. The main responsibilities of the component are adjusting the physics properties of the associated PrimitiveComponent and highlighting it when it is in range of a glove or pearl spark.
The WhaliumComponent sets the following attributes on the specified PrimitiveComponent:
We wanted to give the player a visual indicator when the specified PrimitiveComponent is in range of a glove or pearl spark. Our WhaliumComponent defines two ways to highlight the PrimitiveComponent, both of which can be used at the same time:
Sometimes actors with WhaliumComponents are required to solve a level, therefore we introduced a reset functionality which respawns these actors if they would be destroyed. To achieve this we save the component’s initial “whalium state” on BeginPlay (transform, moveabilityBehaviour, collision behavior, etc.) and then restore that state if the actor overlaps a ResetZone trigger.
We provide events to notify interested systems/actors that something has changed for the WhaliumComponent and its associated PrimitiveComponent. The most important events of these are, OnChangeInfluencedState, OnPickedUp and OnReset.
We introduced a few flags in the WhaliumComponent in order to gain more control over how a PrimitiveComponents should be influenced by our gloves and pearls:
This concludes the final entry of our core ability series, and we hope you could gain an insight on our design- and implementation choices. As always, we are happy to answer any questions concerning our WhaliumComponent, the other core abilities or any other related topics!
- Andi, Ralf