Hybrid item Types

Ando5000

Member
Looking to create a list of melee weapons that I can throw also. Simple example would be an axe. While its equipped it would function similar to the sword or dagger. But , I would also like to be able to throw it, like the grenades. Is this possible to have hybrid of two item types?

I could just use it as a melee weapon and remove it from inventory while externally creating a prefab projectile. Just wondering if there is a way to create hybrid types already.

If i go with the alternative approach, what is best way to remove an inventory item during runtime?

Thanks
 
This should be already possible. It would be similar to the demo scene where you have both a weapon that can shoot and melee. You'll want to use the same ItemType for both the MeleeWeapon and ThrowableItem actions.
 
Okay, lets use the knife as an example in your demo scene. Its already equiped and ready to be used as a melee weapon. How would i make it so i can throw it? Do i need to make a seperate item?

I tried to add a throwable item script and third person throwable property to the Knife item that is located on Nolan.

I am getting no errors, but cant figure out how to make it launch.

Thanks
 
Which weapon is setup like this? I went to the weapon room and cant seem to figure out how to melee with any of the guns.

Thanks.

You can press B to melee with the shootable weapons. If you also press F1 it'll open up a keyboard mapping within the demo scene.

Okay, lets use the knife as an example in your demo scene. Its already equiped and ready to be used as a melee weapon. How would i make it so i can throw it? Do i need to make a seperate item?

I tried to add a throwable item script and third person throwable property to the Knife item that is located on Nolan.

I am getting no errors, but cant figure out how to make it launch.

Thanks
Did you add the ThrowableItem script through the existing Item Manager? After you do that you'll need to setup a second Use ability so it can be used with a different button. From there you'll want to make sure you have the ThrowableItem's consumable ItemType and thrown object set.
 
Okay, thanks for the help.

I was able to follow this and get something happening. I now have a pickup that functions as a melee and when i press 1 it will toss it, but with a weapon swing animation and the arc is not visible.

I did have some weird behavior. I added a line renderer and a trajectory object script to the knife item set located on nolan. It keeps telling me that i dont have one and only works if i add trajectory object script to the actual equiped knife, but then its disabled when the scene loads!

I will post a walkthrough for this once i get it figured out. Thanks for your help
 
but with a weapon swing animation and the arc is not visible.
You can change the swing animation based on the ThrowableItem's Use Animator Audio State Set. This page describes that interface:


In terms of the trajectory, did you enable Show Trajectory On Aim on the ThrowableItem? The LineRenderer should be on the actual ThrowableItem.

I will post a walkthrough for this once i get it figured out. Thanks for your help
That would be awesome! I can then include it in the docs :)
 
I was able to get this to function properly. when combining the two item types (melee, throwable) its making me add a line renderer and trajectory object to both stored locations for the dagger. The equiped version disables trajectory script on start, but wont run without it. The line render is also required on the equiped version, but altering any of its values doesnt change the aim. but i get errors without it. All the trajectory changes made to the item collection works , similar to the grenade. I am happy with it, its a weird work around but now that i know what to do its very easy.

Lastly, I thought it would be a nice bonus to be able to retrieve the item. I havent found a good way to do this yet as i ran into an issue where the
thrown item is still being weapon swapped after being thrown. When i hit q it pulls the knife back out but its invisible..
 
Last edited:
Another road block is that the thrown item isnt colliding with exploding barrel. There is a collider and the layers are set the same as the melee weapons. I mean its the exact same weapon that is used to melee, so not sure whats going on.

I setup an external script with a second collider set to trigger to handle this, but not really sure why this isnt working naturally on exploding barrels in test scene. One thing i noticed is when i aim at the barrel it falls over lol.
 
Last edited:
I was able to get this to function properly. when combining the two item types (melee, throwable) its making me add a line renderer and trajectory object to both stored locations for the dagger. The equiped version disables trajectory script on start, but wont run without it. The line render is also required on the equiped version, but altering any of its values doesnt change the aim. All the changes made to the item collection works , similar to the grenade. I am happy with it, its a weird work around but now that i know what to do its very easy.
When you say both stored locations, what locations are you referring to? The LineRenderer/TrajectoryObject needs to be added to the ThrowableItem in order to have the arc visible, and the TrajectorObjecty needs to be added to the thrown object so it knows which direction to move.

Lastly, I thought it would be a nice bonus to be able to retrieve the item. I havent found a good way to do this yet as i ran into an issue where the
thrown item is still being weapon swapped after being thrown. When i hit q it pulls the knife back out but its invisible..
You'll want to make sure you have enough consumable item types for the weapon to throw. I thought on the ThrowableItem there was an option to keep equipped even if it was out of ammo but I can't find that option. I've written it does to add.

Another road block is that the thrown item isnt colliding with exploding barrel. There is a collider and the layers are set the same as the melee weapons. I mean its the exact same weapon that is used to melee, so not sure whats going on.
You can debug this within Destrucatble.OnCollision - when the collision event for the barrel occurs it should damage it at the end of this method.
 
Yes, both stored locations are as you suggested. Setup seems to be as intended then. Working on debugging the collision now.

Next step:

I would like to throw the item and have it remove from inventory completely. Its lingering invisible and is selectable with the weapon wheel. Seems to be buggy due to it being a melee and a throwable item. Its playing a put away animation after throwing it. The throw itself is a melee slash. Not intended, cant seem to figure out how you have animations setup. Is this tied to audio files? Do i need to play the grenadetoss audio in order to use that animation? (ive tried copying what was on the grenade but not working)

Side note When i look at the hierarchy the item is disabled after throwing, like it should be. But, its still there on the weapon wheel.
 
I would like to throw the item and have it remove from inventory completely. Its lingering invisible and is selectable with the weapon wheel. Seems to be buggy due to it being a melee and a throwable item. Its playing a put away animation after throwing it. The throw itself is a melee slash. Not intended, cant seem to figure out how you have animations setup. Is this tied to audio files? Do i need to play the grenadetoss audio in order to use that animation? (ive tried copying what was on the grenade but not working)
That sounds like it could be related to the option that I thought was there related to keeping the item equipped even if there aren't any consumable item types left. ThrowableItem.StopItemUse will equip the next item if the consumable item type count is zero. Thinking about this some more if you are out of axes to throw, why would you want to keep it equipped?
 
That sounds like it could be related to the option that I thought was there related to keeping the item equipped even if there aren't any consumable item types left. ThrowableItem.StopItemUse will equip the next item if the consumable item type count is zero. Thinking about this some more if you are out of axes to throw, why would you want to keep it equipped?

In this scenario I would NOT want to keep it equipped, this is what i am trying to avoid. I think its safer to consider this item disposable one of. It needs to function as a throw able item that can be melees, i suppose more so than the other way around. Consider a walk through a tool shed. You find random tools that dont necessarily get you excited, but that wrench or hammer on the wall might be fun to throw once after you've tested out a few melee opportunities.

For this case I want to throw it and unequip it from inventory with this invisible render + weapon wheel icon bug gone. Next, If the user likes the outcome. Im creating a way to have the option to pick it back up or pull the item out of a victim via a pickup attached to the throwable item to place it back into inventory.
 
Instead of going back and forth can you send me a repro scene so I can take a closer look at it?
 
Top