As the title says, I’m trying to add my own melee weapon to the game using the scriptable objects that the tutorial took you through. I’m having trouble and don’t know where to start. I have a animation for a flame sword swing, and I want to be able to play it with left click. I also want to try to make the prefab of the object show up next to the player. How could I go about doing this?
Hi yuun, here are some steps to guide you along the process of adding a new melee weapon to your game.
First, you have to decide what your weapon’s type is. Since you have said that you want to add a melee weapon, you can skip this.
Afterwards, you have to create your own scripts and derive them from the Weapon Base scripts we created in the Tutorial Series. Since you have stated that you have a Flame Sword animation, I presume you intend you create a Flame Sword weapon. In that case the two scripts would be FlameSwordController and FlameSwordBehaviour.
These two scripts will handle all functionality for the Flame Sword. You can add in a reference to the animator here to animate the swinging.
I’m not sure what you mean by making the prefab show up next to the player, so perhaps you can explain more about that.
Hopefully this helps!
Keep in mind that this is a very general layout of how to add a new melee weapon using the system we built in the Tutorial Series.
When I said the flame sword next to the player, I meant that the sword would show up as if the player is holding, it, thus being next to player model. Also I did actually find out a way to do all of this through more research! Also, when the animation is playing, I have a box collider on the flame sword that will turn on at a certain point in the animation. It only sometimes works for some reason.
Hi yuun, if you want to make it attach to the player, that is a whole new layer of complexity to it. We’ll need to create a new equipment system to support this. It’s not a small task.
I’m revamping the weapon system in this series to become more versatile, so you may want to keep your eyes peeled for that, though it should not arrive until next year.