Moving to Physics Driven Combat

The Reason

In my previous post I talked about different ways I could move the sword to make it feel more natural and satisfying to wield. After implementing the system using Unity’s SmoothDamp() (the first of the two), I discovered that it did not make a tangible change to the feel of the game. The interpolation still felt robotic.

…and collision between swords is still broken.

I’ve decided to make a separate branch in my github repository to experiment with replacing the current sword movement methods with physics. If it works, I’ll merge the changes to the main branch, if everything gets broken, I’ll just abandon the branch.

The Physics Driven System

I started devising how I could go about driving the sword using physics through a combination of browsing through the functions available to Rigidbodies in Unity’s API, along with some problem solving.

After discovering the AddRelativeTorque() method, I figured moving the sword around would relatively painless to get going. The hard part would be clamping how far it can go, along with re-centring the sword when the player is not using the right-stick.

I sketched out one-way I could go about it:


Essentially, there’s a counter force used to recenter the sword, as it gets further away from the centre, the forces acting against its movement get multiplied by the angle between the sword’s resting position to its current position. Eventually, the forces acting against the sword will negate the forces moving the sword, naturally defining the range of the sword’s movement.

When the player releases the stick, the forces will push the sword back towards the resting position. Potentially, if the player were to hold the stick in one direction then flick it to the opposite side, this could result in a slingshot effect as the forces pushing the sword back are added on top of the forces from the player’s input, essentially adding the ability to charge attacks.

And since this is all based on physics forces, there will be natural acceleration and deceleration in combat without requiring additional systems.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this:
search previous next tag category expand menu location phone mail time cart zoom edit close