ThrowableItem Grenades

GreedyVox

Active member
Help wanted with throwing Grenades.

We don’t think this is a bug but most likely a set-up issue, we have runtime pickups for all our weapons and everything is working, however when we pickup a Grenado, the very first throw working as designed, but when we tried to throw again, the Grenado is stuck in the players hand and blows up killing the player and all those close by, throwing a null exception for the global variable m_InstantiatedThrownObject, in the ThrowableItem.cs from the public function ThrowItem ().

EXAMPLE

ABILITY
Screenshot from 2021-08-11 20-01-46.png

FIX
Code:
if (m_InstantiatedThrownObject == null) {
    Debug.Log ($"<color=blue>Grenado is thrown? [{m_Thrown}]</color>");
    return;
}

m_InstantiatedThrownObject.transform.parent = null;

Adding this null checker to the script, just before the line m_InstantiatedThrownObject.transform.parent = null, fixes the error exception and everything working, no more Grenado blowing up in the players hand.

We have gone through all settings and cannot find what is wrong, this also happens in both single and multi-player tests, and it does feel like we are missing a settings somewhere, have also noticed that this function is called twice throwing exception on the second pass, but that's the problem, this function is being called twice.
 
Last edited:
The grenade animation events have changed so they are per slot. If you are using the default set of animations you can either enable the use slot or do it based on a timer. In the next update I've changed it so by default it uses a timer.

1628675253925.png
 
I have ticked the Wait For Slot Event and created the "OnAnimatorItemUseFirstSlot" on my throw animation event, is this being used more than once in the default animations?
When I test with the Opsive Demo controller/animations and the original Opsive Throwable.cs script without the Null Checker added, the grenade is thrown once, then unable to throw a second time.
 
Just some other notes about the Grenade. I myself have ran into this "issue" where the first throw of the grenade but after that it randomly can happen but the grenade explodes during the throw. I thought it was something with the colliders but it doesn't seem to be it.

So it seems that we have to make sure that "Wait For Slot Event" to be checked to fix this?
 
So you're saying in a fresh project you can only throw the grenade once?

So it seems that we have to make sure that "Wait For Slot Event" to be checked to fix this?
Yes. The grenade animation event now indicates the slot id. This was to prevent the grenade from being thrown when for example the assault rifle was fired at the same time.
 
Yes, I have recreated the grenade runtime pickup from scratch in a fresh project and I come to the same issue. i am currently going through my animation/Mecanim event setup looking for the problem.
 
OK,
We have found the culprit, further backend code investigation has revealed I had an extra 'USE' ability custom setup added in my item abilities within the character locomotion and this was set to automatic start & stop type.
I was creating a custom Melee counter attack item abilities in the past and had left this in by accident which caused my grief today.

Thank you all for your help.
 
Top