[OPEN SOURCE] Lock-On Combat in 3D

Introduction

Hello everyone,

Over the years i’ve seen numerous kinds of Roblox games evolve, from the paintball games of the early 2010’s to phantom forces, from speed run 4 to a full on remake of the first Super Mario Bros, and from small maps to full open worlds and RPGs, these have all evolved.

There is one genre that I still feel really hasn’t reached the potential it has though, and that is Melee Combat

Melee combat has seen some improvements over time, but nothing compared to other games. We’ve gone from linked swords in Sword Fight on The Heights to games where shiftlock is used to direct attacks, but still with the same sort of concept.

That isn’t to say that these games are bad per say, but I believe we are missing out on a huge opportunity with how we design our 3D combat mechanics, one system that most 3D games today use themselves.

This system is lock on combat

Lock-On Combat, What is it and where is it from?

Lock-On combat is a type of targeting system used by many modern day 3D games that have a combat system, and may sometimes be referred to as Z Targeting

The term was coined by The Legend of Zelda: Ocarina of Time on the Nintendo 64, and was used to help guide players with their attacks on enemies by point their avatar towards the enemy they target to help direct their strikes.

This was done because when the jump from 2D to 3D was being made, game designers were forced to rethink many traditional combat systems. With the original Zelda game, all the player needed to do was point their avatar in one of 4 directions. In 3D however, this is not the case.

Why Make Use of Lock On?

Many games currently use a system where the player turns on Shift Lock in their settings and aim their attacks by moving the mouse, thus in turn moving the camera and the player.

While this system does work, this results in most of the games skill becoming how the player can position their camera accurately, not interaction with the combat system itself.

This can be very clearly seen in numerous games, as most games of this type have one basic attack or with some a second one, a block/counter move, a dash move, and sometimes a flip.

This block usually has no openings to it, its based upon reaction time, or if it does have an opening it is on the back of the player. With this kind of combat, the shiftlock system is carrying most of the skill in the game with positioning and aim.

On top of this, slow methodical combat is impossible with this, or at least very difficult to design naturally. With the shiftlock camera system, it essentially turns the game into jump position attack. It is more viable to simply be on the move with it.

With a lock-on system, you remove that element entirely. This allows for numerous new design possibilities, and let’s the concepts be more explored.

Some games that showcase this really well are games like The Legend of Zelda series and For Honor, both of which use Lock-On systems.

This isn’t to say these other systems don’t have value, but what I am saying is we should broaden our scope on combat systems on the Roblox platform.

Template Lock-On System, how does it work?

Here I have constructed a template place for a lock on combat system, with some basic mechanics:

Move your mouse to adjust your guard, which is how you block incoming attacks and direct your attacks

Running out of stamina makes your attacks slower and you take damage when blocking

Right click after attacking to fake attack

Attack before an opponents attack lands to parry them

Known Issues and Design setbacks

One of the massive setbacks with this system can be teaming with the combat system.
Because of how this combat is structured, 1v1 combat is geared towards the most. This makes handling teaming very difficult//Impossible

I have not made this compatible with NPCs. Yes, you can damage the dummy and it will block you, but this is the extent of it. You’ll need to program it yourself or alter it for NPC combat.

NPC combat can be difficult to program with this, personally i recommend having testers play and noting strategies used by them for NPCs to imitate.

These sabers use RaycastHitboxV3, a raycast module made by Swordphin123. This is an outdated version of it, and some rescripting may be needed for upgrading to V4 if you so desire. More information is here on the devforum post : Raycast Hitbox 4.01: For all your melee needs!

Lag problems

Many checks and events are fired when the game is running, this basic system is meant to be a proof of concept and I highly recommend optimizing it for future use.

The best optimization for this system by far is a custom render for the block animations when it changes for the angle.

The second optimization I’d highly recommend if you plan on using this as a template for your game is replacing the cooldown systems for attacks. The loop style is extremely inefficient and will cause major lag throughout your game. From what i’ve gathered using functions like task.delay() and multithreading are extremely useful for this.

Another possible optimization is the input event for the mouse, which I currently have set to send every .1 seconds.

Here is the template place, enjoy everyone!

https://www.roblox.com/games/7354346829/Lock-On-demo

I hope to see more lock on combat games in the future, and thank you for your time. Have a great day everyone!

104 Likes

I have recently learned the fundamentals of programming and I find this to be very useful to get introduced into LUA and understand it all. Thank you for such an organized and methodological open sourced resource.

4 Likes

This is a nice tutorial.

I would say that while this is true in some cases, most of the time it won’t affect the skill required to interact with the system itself.

2 Likes

nice,goodjob,It seems that it can finally create a good action game experience

2 Likes

Is it possible to convert this to R6? Or will it break with doing so

2 Likes

The only things that would break as far as I’m aware are the equipping functions and a few camera functions.

The equipping functions would break because in the sword server script the functions “makeHandWeld()” and “makeBeltWeld()” use attachments that are only on R15 models.

The camera scripts in StarterGui.Guard.Client would break for the First Person mode stuff which can easily be changed to Torso.

In theory it should be decently easy to convert this to R6, though you’ll need to modify quite a bit of code bits and could lead to some unforeseen bugs later on. Id recommend doing R15 with R6 style animations.

2 Likes

Thanks so much! I’ll look into doing it now.

2 Likes

I’ve noticed when you die, 9/10 the camera will bug. Is there a way to fix this?

1 Like

I would need to take a look back at the code, I will be making a 2.0 version of this framework soon with stability improvements and such.

3 Likes

Didn’t expect to actually learn so much from this. Can’t wait for the 2.0 version.

2 Likes

You should make it compatible with larger r15 rigs. Just some advice

2 Likes

i hope you will make 2.0 demo version of this. This is best combat system i’ve seen so far

1 Like

This is a very good demo imo, I look forward to V2 of this!

1 Like

I actually have! It doesn’t have the same directional angle system but it does focus on the Z targetting aspect much much more. Here’s the link if you’re interested [OPEN SOURCE] Updated Lock-On Combat in 3D

1 Like