Weapon Collider

I have a question. originally I had a 2d Capsule Collider over my sword instead of what was in the tutorial. I still want to keep that on the sword. since we changed the “Player Controller” script to drag in the Weapons Collider I can’t do that anymore. Is there a way I can still do it the way I originally had it?

Thanks.

You should still be able to use the 2d Capsule. That being said, one of the advantages of the WeaponCollider over a collider on the sword is the possibility of swinging “through” an enemy, if the swing is faster than the current physics frame rate.

Either way, whether you stick with your own collider, or use the WeaponCollider, I promise not to dock your grade. :slight_smile:

so, what do I do for this Capitula collider? not make it a Serialized field? And if so how do I get it to the Player Controller?

You should be able to leave it on the sword, and the Rigidbody2D should pick it up. If it doesn’t pick it up, you may need to put a Rigidbody2D on the same GO as the sword and put a Damage script on it.

I’m talking about this field on the Player.

Ah, for turning it on and off… the tricky part about linking the collider on the sword is that we’re spawning in the sword at runtime (or will be if you’re not that far in the course), meaning that the player will need a link to it to turn it on and off.
I’m at work atm, but when I get home, I’ll take a dig into the code and find the best way to accomplish this.

Actually, looking over the code now that I’ve gotten home, the WeaponCollider reference on the PlayerController is just so that it can be a passthrough for the Sword to turn the collider on and off. We don’t need to add the collider to the PlayerController because the Sword should have a reference to it. Make a serialized field on the Sword and link the collider on the sword. Then simply turn it on instead of turning on the PlayerController.WeaponCollider.

Thank you That worked !!

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms