Share
Explore

Replicated Hitbox System

👾
🎮
🌟
Introduction
This project allows you to easily and quickly add fully replicated animation hitboxes, projectiles with adaptable collision and different spawning methods, as well as damage volumes to your animations/world. The system uses C++ but no knowledge of C++ is required!

Features
Customize it, Make it yours - Allows you to customize the system even in real-time.
Plug & Play - Simple Actor Components to be initialized and the rest is history.
Simple Blueprints - The system is mostly in blueprints with some base classes in C++, coded with optimized industry standards. No C++ knowledge is required!
Fully Replicated - The entire system is replicated over the network and can be played in multiplayer.
Animation Hitboxes - Be it an RPG or a fighting game, add flexible hitboxes to your animations with simple AnimNotifyStates.
Projectiles - Use our projectile class with an adaptable and modifiable collision shape! You can also modify everything from the damage to the speed and VFX.
Projectile Shower - Want to rain down hell on your foes? Fear not, for all you need is a simple AnimNotify. Set the extent of the hellish rain, the projectile speed, the damage and much more!
Homing Projectiles - Are simple projectiles not cutting it for you? Try our special-made homing projectiles. Not only can you set the homing target and speed as well as the damage and the collision shape, but you can also spawn them in bulk and in different methods.
Spawn Methods - Want to spawn your homing projectiles along a vector? Or maybe randomly in a box? Perhaps you’d like them to spawn in a circle? You’ve come to the right place. Use our commented algorithms and don’t let your foes know what’s coming for them.
Damage Volumes - Spawn damage volumes with adaptable collision shapes and deal damage to everything and everyone inside for as long as you need them to suffer!
Controls
T_Controls.png
Initial Setup Video

Collision Setup
Open your Project Settings and head into Collision under the Engine category
Create a New Object Channel called Projectile set to Ignore
image.png
Create a New Trace Channel called Hitbox set to Ignore
image.png
Create a New Preset called Projectile with Query Only as the CollisionEnabled, Projectile as the ObjectType and set to Block only World Static, World Dynamic and Pawn channels.
image.png
If you want your projectiles to interact with the world, make sure that the collision response for the BlockAll preset is set to Block for the Projectile object type
image.png
Same goes for animation hitboxes.
Under AuroraDevs_RHS/Blueprints/Characters, open BP_ThirdPersonCharacter.
Click on Class Settings
image.png
Make sure that the class implements the BPI_Hitbox interface.
image.png
This interface is used to broadcast damage to both attackers and victims as well as reduce health
image.png
Click on Capsule Component and scroll down until the Collision Category in the Details Panel
Make sure that both Simulation Generates Hit Events and Generate Overlap Events are set to True
Make sure that the collision response for both Hitbox and Projectile is set to Block
image.png
Now for replication to work, select your Mesh in the Components Panel then scroll down until the Optimization category in the Details Panel.
Make sure Visibility Based Anim Tick Option is set to Always Tick Pose and Refresh Bones
image.png
Compile and Save
Under AuroraDevs_RHS/Blueprints/Actors/Projectiles, open BP_RHSProjectileBase.
Under the variables category Collision select CollisionChannel and set its default value to Projectile
image.png
Compile, Save and Exit
Don’t forget to add a DefaultSlot to your AnimBP in order to play animation montages
5.DefaultSlotAnimBP.png

Replicated Hitbox System
Animation Hitbox Notifies
image.png
Setting up collision hitboxes in animations is as simple as ABC.
Open your animation in the Unreal editor.
Add the AnimNotifyState BP_HitboxAnimNotifyState
image.png
Click on the newly added notify state and go to the Details Panel.
You can modify a couple of settings in here such as the damage, the trace channel and the debug duration/thickness. You can also toggle debugging in-game. Most importantly, you can setup the collision shapes, their size and their attachment.
image.png
Click on the + sign next to CollisionShapes to add a collision component
image.png
Choose what type of shape you wish to add. We shall select Sphere for demonstration purposes
image.png
You can set the size of your collision capsule and its attachment bone/socket.
image.png
In our animation, we will choose hand_r. We can notice that the shape isn’t quite placed correctly
image.png
We shall adjust the LocationOffset accordingly, by setting it to (-32.0, 12.0, 0.0) in Bone Space.
image.png
image.png
Keep in mind that the offset can be performed in World Space, Bone space, Component Space or Parent Bone Space.
World Space: The offset is applied in the general world frame of reference. This is usually not useful for such type of animation hitboxes but the choice is there if you want it.
Bone Space: The offset is applied in the reference frame of the specified bone. Click on the bone to which the collision is attached in order to help you better visualize the axes and the directions along which the offset will be applied
image.png
Component Space: The offset is applied in the Mesh’s reference frame. This means that the hitboxes will simply rotate with the character since the offset is applied in the ROOT’s frame of reference. Click on the root in order to help you better visualize the axes and the directions along which the offset will be applied
image.png
Parent Bone Space: The offset is applied in the parent of the specified bone. Click on the parent of the bone to which the collision is attached in order to help you better visualize the axes and the directions along which the offset will be applied. In our example, the parent bone of hand_r is loweram_r
image.png
❗MAKE SURE THAT THE SELECTED BONE HAS A PARENT ❗

Side notes:
You can make the collision shapes rotate with the bones by checking the bRotatesWithParent box.
image.png
image.png
bRotatesWithParent set to FALSE bRotatesWithParent set to TRUE
You can add multiple collision shapes in the same notify by clicking on the + sign again. This allows you to trace complex collision shapes with ease
image.png
❗However, each notify will only hit the same actor once (to avoid the same actor getting hit on each frame from the same notify)❗

Simple Projectiles
image.png
image.png
Setting this one up is quite simple. All you’ll need to do is open your projectile throwing animation and add the AnimNotify called BP_SpawnProjectileAnimNotify. You can then set the projectile class, which has to be a child of BP_RHSProjectileBase, the attachment bone/socket, the transform offset from the parent bone/socket as well as the projectile speed.
image.png
image.png

If you wish to modify the projectile’s damage, trace channel, visual effects or even collision shape, create an new child blueprint of BP_RHSProjectileBase and you can set these under the Details Panel.
image.png
Since this is originally a child of a C++ class, you can choose from both Cascade or Niagara!

Furthermore, your projectile’s collision shape is adaptable. Simply set the shape you want under the Collision Shape category in the Details Panel.
Sphere Collision
image.png
image.png
Capsule Collision
image.png
image.png

Box Collision
image.png
image.png

❗ Because the root component of any class inheriting from RHS_AdaptableCollisionActor is changed at runtime, there is something important to keep in mind when adding new scene components to the these classes (static meshes, skeletal meshes, FX, etc..): make sure that Component Replicates is set to True!
Otherwise, you will receive some errors in the output log, especially when playing in multiplayer ❗

Projectile Rain
image.png
Probably one of the simplest features of the plugin, Projectile Rain rains down a shower of projectile in the bounds of a collision box. The duration, fall speed, XY deviation of the falling projectiles, the spawn frequency as well as the size of the box are all modifiable.
You can also choose the type of projectile class to spawn.

To use this, you can either put the BP_RHSProjectileRain actor in your level and configure it directly in the spawned actor’s Details Panel, or you can spawn it through an animation with the BP_SpawnProjectileRainAnimNotify, in which case you can modify other settings such as the location offset, etc.
image.png
image.png

Beams
image.png
Beams are a special power that can be used by character through the AnimNotify BP_RHSBeamAnimNotify. In its settings you can configure the duration of the beam, how frequently it damages other actors, its spawn attachment socket and transform offset as well as the beam class itself.
image.png

All beams are children of the BP_RHSBeamBase actor. You can created a child of this class in order to modify the beam’s length, duration, VFX, the base damage, the collision channels and the trace radius.
image.png
image.png

It’s important to note that the variable WorldTraceObjectTypes specifies the types of objects against which the beam is allowed to collide.
image.png
Without adding Pawn, the beam goes through the character but stops at the World Static Object:
image.png
This does not affect the damage❗ The collision channel used for damage traces (Projectile) is different than the one used for detecting the end point of the beam. The beam in this case will go through all pawns while damaging them and only stop when an object of a type included in WorldTraceObjectTypes is collided with or when the trace duration is exceeded..
By adding the Pawns object type the beam collides with the character and stops:
image.png


Damage Volumes
image.png

Damage volumes are volumes with adaptable collision shapes that can be spawned either by being placed manually in the level or through the AnimNotify BP_SpawnDamageVolumeAnimNotify and that damage all overlapping actors each X seconds.
In the anim notify, you can set the lifespan and the damage rate as well as the offset of the damage volume. All damage volumes are children of the BP_RHSDamageVolume class.
image.png
Inside a child of the BP_RHSDamageVolume class, you can modify the VFX, the base damage, the collision channel as well as the collision shape of the damage volume
image.png
Like projectiles, you can set the ShapeType to be a box, a sphere or a capsule and configure its size.

❗ Because the root component of any class inheriting from RHS_AdaptableCollisionActor is changed at runtime, there is something important to keep in mind when adding new scene components to the these classes (static meshes, skeletal meshes, FX, etc..): make sure that Component Replicates is set to True!
Otherwise, you will receive some errors in the output log, especially when playing in multiplayer ❗

Homing Projectiles
image.png
Setting this one up is quite simple. All you’ll need to do is open your projectile throwing animation and add the AnimNotify called BP_SpawnHomingProjectileAnimNotify. You can then set the projectile class, which has to be a child of BP_RHSHomingProjectileBase, the attachment bone/socket, the transform offset from the parent bone/socket as well as the projectile speed.
image.png
You can set the homing acceleration speed, i.e, how quickly the projectile will close in on the target. You can also set a delay before the homing begins as well as the initial velocity direction once the projectiles spawn.
For example, if we set the SpawnInitialVelocityDirection to (X=0, Y=0, Z=1) and the DelayBeforeHoming to 1, then when the projectiles spawn, they will first go directly upwards then start homing down on the target after 1 seconds elapses. You can see this in action:
ezgif.com-gif-maker (2).gif
If you want the projectiles to go forward, simply set SpawnInitialVelocityDirection to (X=0, Y=1, Z=0). If you want them to not move until the HomingDelay has elapsed, set the SpawnInitialVelocityDirection to (0, 0, 0).

What’s different from simple projectile spawning is that you can use this notify to spawn homing projectiles in bulk. You can choose how many to spawn, their speed, as well as how deviated they are from the initial velocity direction.
image.png
In the previous GIF, you’ll notice that even though the SpawnInitialVelocityDirection was set to (X=0, Y=0, Z=1), the projectiles did not go straight UP. That is because we have set MinXYRandomVelocityDirection and MaxXYRandomVelocityDirection to -0.25 and 0.25 respectively.
This means that each projectile will be deviated slightly in the X and Y axes so as to make the projectiles more realistic. If you want the projectile to go straight along the SpawnInitialVelocityDirection, simply set the previous Min Max values to 0.

Spawn Methods
Now comes the most exciting part, the methods by which the homing projectiles are spawned. You can set these under HomingProjectileSpawnSettings inside the AnimNotify details
image.png
You can choose between 3 methods:
Evenly Along Vector: Projectiles will spawn evenly along a vector and they will be spaced according to the SpawnLocationVariance vector’s X,Y and Z values. For example, a value of (X=32, Y=0, Z=0) will make the projectiles spawn along the Mesh’s X axis and they will be exactly 32cm away from each other:
image.png
SpawnLocationVariance = (X=32, Y=0, Z=0)

image.png
SpawnLocationVariance = (X=32, Y=24, Z=28)
Randomly in Bounding Box: After specifying the bounds of the bounding box by setting the SpawnLocationVariance vector, the projectiles will spawn randomly inside this box. For example, a value of SpawnLocationVariance = (X=50, Y=50, Z=12) will make the projectile spawn randomly inside a box of 12cm height, 50cm width and 50cm length.
image.png
Evenly in Circle: You will spawn the projectiles evenly in a circle. You can set the radius of the circle and its max angle as well as the rotation axis of the circle. The rotation axis of a circle is the vector perpendicular to it and looking away from it.
cats.jpg
In this example, the radius is set to 100cm, the rotation axis is set to forward which is (X=0, Y=1, Z=0) and the max angle is 180 (90 + 90) degrees.
You can also set a completely different rotation axis and tune up the max angle to 360 degrees so that the projectile spawn all around the character:
image.png
CircleRotationAxis = (X=0, Y=1, Z=1), CircleRadius = 100, MaxCircleAngle = 360


Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.