Making it Fun – Moving the Sword

What Currently Happens

Applied to all movements of the sword, there’s linear interpolation (Mathf.Lerp()) applied so that the sword naturally moves to wherever the player is moving the right stick instead of snapping to its target. This does however sacrifice responsiveness and swings of the sword, while smooth, don’t have any weight or power behind them.

This is because that while motion is smooth, there is no acceleration or deceleration. Acceleration is a vital component of creating natural animations whether that be physics based or kinematic.

Image result for acceleration and deceleration in animation gif
Graphical demonstration of using curves versus linear interpolation. (Source

Solution 1 – Alternate Interpolation

While searching through Unity’s API, I came across another interpolation function (Mathf.SmoothDamp()). It works much like a springy Mathf.Lerp(), with extra parameters to add acceleration and deceleration to the interpolation. The similarities of calling the two functions should mean that implementation of this will be relatively straightforward.

However, since the rotations are still kinematic, this will most likely not solve the problems currently being exhibited with the collisions between swords.

Solution 2 – Using Torque

Currently the sword movement system relies on kinematic rotations of the TargetParent GameObject. Another approach would be to take the RigidBody component of the TargetParent and apply a physical Torque to it.

There are a few caveats with this approach however: The biggest one being that it will lead to a significant overhaul of the current sword movement system as most of the functions in there are designed to feed into the current kinematic rotation model.

On top of that, while this will result in acceleration being applied, I’m unsure about the deceleration prospects. Once the TargetParent hits the rotation clamp, the rotation will suddenly stop. That is unless I replace the rotation clamp with a counter force to the TargetParent’s rotation that gets multiplied depending on how extreme its angle is.

This could however be the key to solving the sword collision detection problem.


Given the fast approaching time constraints of this unit, I’m much more inclined to go for the first solution and see how that fares. If I believe the latter solution is the only way around the collision detection issues and I still have time left, then I will attempt that as well.

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 )

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