Custom Spear Throw Questions

nathanj

Active member
Hello,

I'm working on a spear throw and kind of have it working but looking for some input, if possible.

At the moment my spear is a throwable item and it kind of works, i can throw it and use the Trajectory Object to show where it is going. However, I would like to be able to add something like the Fire Type Charage and Hold of the Shootable Item so the player can choose how much velocity to apply to the spear throw. I would also like to be able to pull the players arm back while they increase their throw velocity.

I've tried converting the spear to a shootable item but for some reason I can not get it to work and I'm not sure why.

Anyways, I've been messing with this all day and am hoping for some general direction as to what approach I should take.

Ideally, the throw would also include aim/lock.

So to summarise, if it's not too hard would you mind giving me a ballpark idea of how you would approach making a spear throw that has aim/lock and velocity with button press time - the trajectory line renderer is not necessary.

Thanks in advance
Nathan
 
Using a ShootableWeapon is certainly the easiest option - what issues are you having with converting it? It would probably be easier to just create a new ShootableWeapon item. You'd then probably need to extend your animator controller a bit for the arm movement during the charge hold. There is an Aim Assist that you could use for a lock-on effect (although I'm not 100% sure how this works with a projectile weapon).
 
Hi Andrew,

Got sidelined for a few days, just getting back to this.

So I figured out why the Shootable wasn't equipping, I needed to add two instances of Spear to the Item Definition Amounts of the Item Pickup - I assume that this is because the weapon and the ammo (consumable) are the same item. I should add that with the posted image the player's inventory only contains 1 Spear after the item is picked up.
SpearIDA.PNG
Adding an amount value of 2 did not work.

However, now I am stuck with not being able to aim or throw the item. Would you suggest I duplicate the Bow Substate on the player's Animator Controller, remove the unncessary links to the actual Box Animator OR should I make a new substate for the spear throw. For having spent a year with UCC I haven't really gotten very far into the animator controller beyond basic abilities for aplogies if the above is kind of an obvious question.

Been messing with this all day and am slowly understanding it but any direction at this point would be greatly appreciated.

Thanks as always,
Nathan
 
Starting with the bow substate is a good idea, yeah - you may end up wanting to tweak it later on to better suit your unique throw animations, but it's certainly a good starting point.

For the inventory issue - you're increasing the amount in the default inventory but it's still staying at 1? I'm not sure exactly what happens when you have a consumable item definition be the same as the weapon itself. In general I'd recommend against this anyway - e.g. have a Spear and a SpearThrowable.
 
Thanks Andrew

So I have a Spear and SpearThrowable and I can collect it the item and throw it! But my animations are not triggering at all, I do get the Pullback audio to trigger and the weapon is fired but there is no visual indication anything is happening. I watched the Shootable Weapon set up again but it doesn't really explain how the animations IDs work. You mind explaining or pointing me in the right direction for understanding how equipped weapons realate to animation states?

I've made a duplicate of the Bow Animator substate and changed all the Slot1Itemxxx to Slot0Itemxxx but that didn't seem to make a difference.
subState.PNG

I've changed the Animator Item ID to 7 thinking this would be for the Slot0ItemID value but I do not believe they are related.
Item.PNG

One more thing, can you think of a way that I can have the spear unequip and remain unquipable if the Ammo (SpearThrowable) is 0?

Sorry for all the mundane questions on this.

Thank you
Nathan
 
A couple of notes on Animator parameters:
- Slot0ItemID is indeed set according to the (slot 0) item's Animator Item ID.
- Slot0ItemStateIndex and Slot0ItemSubstateIndex are set by the ItemActions on the item - e.g. the Animator Audio section in an ItemAction defines the Item Substate Index. So you may need to check those values on your ShootableWeapon component and make sure they match up with the values defined in your Animator's transitions.

For the last question, in the ShootableWeapon component, you can disable "Can Equip Empty Item" under the "Use" section.
 
Hi Andrew,

Appologies for the delay, having to work on this on the side as I've got a few other things taking priority atm.

I'm getting there but now I have two questions.

#1. Is there a way to delay the prokectile from being instantiated until the throw animation is completed? I can't find anywhere that controls the time at which the projectile is created, it seems to be as soon as Fire is called - which works for the bow but a spear throw requires a bit of a delay.

#2. Because I am using a Weapon (Spear) and Ammo (spear Projectile), when I throw the spear the weapon is still equipped in my characters hand, but I would like to unequip this. I have it set to not be equipable if the ammo count is 0, thanks!, but I would like to unequip automatically if the ammo count is 0. Should I use a State to do this or is there a better way you can think of?

Thanks again for all your time and patience with me on this.

Nathan
 
1. You could either edit the animation's events timeline and move the OnAnimatorItemUse (I may have gotten that name slightly wrong) to be played later in the animation, or disable "Wait For Animation Event" in the ShootableWeapon's "Use Event" and set a custom timer.

2. I believe the only way to fully unequip an item once it's empty would be to manually start the EquipUnequip ability upon detecting that the consumable item amount is 0. You could do this by listening to the OnItemUseConsumableItemIdentifier event.
 
Top