Trying to make a first person character throw a ball

Temmy

New member
Hello,

I've set myself a tiny challenge to start understanding UCC which is I want to create a first person character, with first person arms, which can throw an infinite number of balls.

(I thought this would be sensible to start with because there are already animations in the demo for first person arms doing grenade throws, and I was hoping I could leverage those to get something working.)

I've followed the steps from tutorials of creating a new character, and a new (throwable) item however I'm not seeing the results I expect. I never see a ball held in the hand (or thrown) and the arms seem to disappear.

Figured it was easier if I captured a short video of the whole process, so if anyone is willing to give it a watch and tell me where I'm going wrong, what steps I've missed, what I need to do next....etc I would be very grateful!

 
Last edited:
For not seeing the ball visible in the player's view, have you moved the ball visible gameobject to the right position (i.e. held in the hand)? Whilst in play mode, go to the scene view and find the visible gameobject and see where it's positioned. Also double check the ball item object's FirstPersonPerspectiveItem properties, i.e. check the render object and visible item fields are set properly and adjust the position offset if needed.

For the arms "disappearing", what are the throwable item's "Reequip" event settings? If you enable animator event logs in the character's AnimatorMonitor component, does the OnAnimatorReequipThrowableItem event get logged?
 

Making progress!

With the help of doing some item tutorials you can see I've pretty much got working what I wanted to achieve which is awesome. Slowly everything is starting to make more sense.

I've run into a couple of questions though:

1) If I spam left mouse button while throwing, subsequent throws don't happen and the arms disappear:


Any clue as to why that would happen? It seems to be fine if I don't spam clicks.


2) When creating the throwable object, I was unsure what type was best to use.

1603135783314.png

In my case I just want a basic object with no additional behaviours or properties. For example, by selecting 'Grenade' a Grenade script gets added to the created object which has lots of things like pins and all that I don't want. What should I go for for a totally simple and basic object?
 
1. This is probably something to do with your item's "Use" settings. In your item's GrenadeItem/ThrowableItem component, open up the "Use" section and see if adjusting any of these values helps - e.g. you probably want to increase the "Use Complete Event" duration, or set it to wait for the animation event. (If you're going to use the animation event, enable "Log Events" on the character's AnimatorMonitor component to check that the OnAnimatorItemUse event is actually being sent by the animation.)

2. There should probably be a Throwable Item option in that object type list, I'd say just create a Grenade, and then swap out the item's GrenadeItem component for a ThrowableItem component.
 
1. This is probably something to do with your item's "Use" settings. In your item's GrenadeItem/ThrowableItem component, open up the "Use" section and see if adjusting any of these values helps - e.g. you probably want to increase the "Use Complete Event" duration, or set it to wait for the animation event. (If you're going to use the animation event, enable "Log Events" on the character's AnimatorMonitor component to check that the OnAnimatorItemUse event is actually being sent by the animation.)

2. There should probably be a Throwable Item option in that object type list, I'd say just create a Grenade, and then swap out the item's GrenadeItem component for a ThrowableItem component.

Re #2, I'm confused here. When you create a grenade object (via the object manager), it creates a prefab which is the object which will be thrown. It is generated with a Grenade (not GrenadeItem) component.

I can't swap this for a ThrowableItem component, because ThrowableItem requires a game object which will be thrown. Which in this scenario would be itself.

Does that make sense?

1603223094841.png
 
Last edited:
I think I've found a sort of solution for now.

It seems every throwable object must have a trajectory component, otherwise you hit this error in ThrowableItem.cs:

1603224627466.png

When an object has a grenade or shell component on it, it seems to pass this check.

For now it seems I can remove the Grenade component and replace it with 'Trajectory Object' and that at least passes the check and removes all the stuff about pins, yadda yadda which I don't want. I'll stick with this for now and see how far that takes me.

I think the sum up of this is; I don't know how this list of object type options is generated, but yes, my feedback would be there should be a super generic 'throwable' option on there.

1603224796696.png
 
Last edited:
Sorry I probably wasn't clear enough - when I said swapping for a ThrowableItem component, I was referring to the the actual item gameobject (under the character's "Items" parent object), not the thrown/visible object.

I confused myself though - that "Object Manager" is actually not for what you think it is. That's more for creating various predefined objects that are used by items/other objects in different ways, e.g. muzzle flashes to be used by a gun, health pickups, etc. To create a new item to be used by the player, you'd create a new Item Type and then use the Item manager to create a new item that way. And in that manager, there's a Throwable Item option in the Action Type.

Here's a couple of videos that demonstrate these steps:

Item Type Creation
Grenade Item Setup (there isn't a video for the Throwable Item setup, but a lot of stuff will be similar)
 
Hey Andrew.

I previously followed the Grenade Item Setup video you linked, and at 2:15 it shows creating a throwable via the Object Manager - which is why I did it.

So should I not be doing that?
 
That's for creating the object that gets thrown, not the item itself. For a simple ThrowableItem, there's no need to use the Object Manager to create the object that gets thrown, since it doesn't need any specific components for the ThrowableItem to work (unlike GrenadeItem, which requires its thrown object to have the Grenade component).

GrenadeItem / ThrowableItem - The component attached to the Item gameobject, e.g. Nolan/Items/RightFragGrenade. Created through the Item Manager. When used, instantiates an instance of the prefab assigned to its "Thrown Object" property.
Grenade - The component attached to the gameobject which is instantiated and thrown by the GrenadeItem component.

So for a simple ThrowableItem, all you need is the ThrowableItem itself, and a prefab which will be instantiated and thrown. This prefab can have any other components or behaviour attached to it you like, such as the Trajectory Object component.
 
So for a simple ThrowableItem, all you need is the ThrowableItem itself, and a prefab which will be instantiated and thrown. This prefab can have any other components or behaviour attached to it you like, such as the Trajectory Object component.

To be clear though, as far as I can tell, when dealing with ThrowableItem the prefab to be instantiated must have a trajectory component, otherwise ThrowableItem will error as mentioned above. So technically you do need specific components to get ThrowableItem working.
 
Last edited:
That's true actually, I was assuming that disabling the "Show Trajectory On Aim" would prevent it from requiring that component but looks like that's not the case.
 
That's true actually, I was assuming that disabling the "Show Trajectory On Aim" would prevent it from requiring that component but looks like that's not the case.
That would make sense to me as well. Either way I'll mark this whole thread resolved bud.
 
Top