Player Controller Version 2

The physics driven method mentioned in the previous blog post has now been implemented, and the game feels a lot better for it. And, even more importantly, collision between swords now works:ControllerNew

Fixing Collision

After searching online, it turns out, Unity does not support collisions between two kinematic Rigidbodies. Unity does however, support trigger events between two kinematic Rigidbodies.

I set the box collider on the sword to a trigger, place a basic print command to be played when an overlap occurs and it immediately works. Problem is, triggers don’t have collisions so there was only one solution:

I fake collisions.

Since the sword is now driven by physics forces, I can apply an impulse force in the opposite direction of the sword’s travel whenever it overlapped with another sword. After implementing it, it’s not perfect, and a bit bouncy but it works. So players can now block incoming attacks.

With that finally working, the core gameplay is done. Leaving me to get to the fun stuff: tweaks and polish.

Polish – Making Clashes Clash

I want to give as much feedback to the player wherever possible. In this case, I wanted a visual cue for players so they know when they have been blocked. I created a simple particle system that is just a big flash, this is attached to the sword and set up so whenever there’s a collision between the two swords the particle will play.

The results are noticeable:Clashes

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