RPG & Fighting Game Integration
RPG & PvPMelee reach validation, combo cooldowns, knockback impulses, and currency transaction safety.
# Overview
Role-Playing Games and PvP fighting games combine close-quarters sword combat, abilities, spells, and currency transactions. RAC ensures combat fairness while supporting fast-paced action.
# Melee Attack Validation Example
-- Server melee skill script
local RAC = require(game.ServerScriptService.RAC.Core.Engine)
local MeleeSwingRemote = game.ReplicatedStorage.Remotes.MeleeSwing
MeleeSwingRemote.OnServerEvent:Connect(function(attacker: Player, targetModel: Model)
local targetHumanoid = targetModel:FindFirstChildOfClass("Humanoid")
if not targetHumanoid then return end
-- Validate melee swing (Max reach 18 studs)
local isValid, approvedDamage = RAC:ValidateHit(attacker, targetModel, 45, "Melee")
if not isValid then
return
end
targetHumanoid:TakeDamage(approvedDamage)
end)
# Knockback & Spell Exemption Handling
Spells or heavy sword strikes that fling an opponent through the air can cause RAC's SpeedDetector or FlyDetector to trigger on the victim.
To prevent this, grant a brief Exemption to the victim when applying knockback:
local function ApplyKnockback(victimPlayer: Player, direction: Vector3, force: number)
-- Grant a 1.2-second exemption for the physics impulse
RAC:AddExemption(victimPlayer, "SpellKnockback", 1.2)
local root = victimPlayer.Character and victimPlayer.Character:FindFirstChild("HumanoidRootPart")
if root then
root.AssemblyLinearVelocity = direction.Unit * force
end
end
# Next Steps
- Explore Obby & Platformers Integration.
- Learn about Vehicles & Custom Movement.