Projectile Replication is the system used and developed by Innovation Inc Thermal Power Plant on Roblox to manage disinfectors.
This project uses Rojo for the project structure. Two project files in included in the repository.
default.project.json
- Structure for just the module. Intended for use withrojo build
and to be included in Rojo project structures as a dependency.demo.project.json
- Full Roblox place that can be synced into Roblox studio and ran with demo models.
Compared to LocalAudio and LocalTween, this system is a lot more involved to set up.
Projectile sounds use LocalAudio for playing sounds. See the setup for LocalAudio for how to add sounds.
The projectiles in the game are stored as data that define the properties and
behavior of the projectiles. At the moment, they are hard-coded to be
MdouleScript
s under ReplicatedStorage.Data.ProjectilePresets
. The
schema of the data for each preset is the following:
number Speed
- Speed that the projectile moves at.number LifetimeSeconds
- The maximum lifetime of the projectile in seconds.string? DefaultFireSound
- Optional sound id to play inLocalAudio
when the projectile is fired from a source.string? DefaultReloadSound
- Optional sound id to play inLocalAudio
when a weapon is reloaded.ProjectileAppearance Appearance
- Appearance of the projectile, which is a table containing the following data:number? LengthStuds
- The length of the projectile in studs.number? Diameter
- Diameter of the projectile.{[string]: any}? Properties
- Additional properties to set.Size
,CFrame
, andParent
will be overwritten if set.
For an example, see the demo projectile.
In order to set up the replication on both the client and server,
ProjectileReplication:SetUp()
needs to be invoked on both the
client and server.
For the Thermal Power Plant, a standard set of scripts are used for all
disinfectors. They are loaded using the helper Standard
module's
CreateStandardWeapon
method. In order to use it, the Tool
must have
a Handle
. The Handle
must have an Attachment
named "StartAttachment"
and optional Attachment
for the left arm named "LeftHandHold"
.
There also must be a Configuration
like the demo configuration.
The standard weapons support Nexus VR Character Model. Adding the loader to the game will make Nexus VR Character Model load when the game starts.
In the case a projectile needs to be fired without using a standard
weapon, such as the turrets in the Innovation Inc Thermal Power Plant, use
ProjectileReplication:Fire(StartCFrame: CFrame, FirePart: BasePart, PresetName: string): ()
.
The StartCFrame
is the starting CFrame
of the projectile with FirePart
being the source part. If FirePart
has an Attachment
named StartAttachment
,
the attachment will be used for playing sounds. PresetName
is the name of
the module storing the projectile data to use.
Pull requests are open for future enhancements that could be made to the system. They have been requested either internally or by members of the Innovation Inc Thermal Plant Discord server.
- Generalized Animations - Animations are currently limited to the hold animation. Reload animations, aiming down scopes, and holding the weapon down for posing are not supported.
- Acceleration - Projectiles follow a straight path instead of accelerating due to gravity or other forces.
- Touchscreen Support - Standard weapons do not support touchscreens. This makes them not work optimally on mobile platforms.
- Fix Multi-Projectile Exploit - There is an active exploit for standard weapons
where the reload delay is ignored as a security check if
ProjectilePerRound
is more than 1. - Fix Arms Bending Unnaturally - See the GitHub issue in Nexus VR Character Model.
This project is available under the terms of the MIT License. See LICENSE for details.