Throw Direction

dereklam0528

New member
Hi,

I have a small ball that I want to throw and after I created the ball using throwable object and using the throw grenade animation, the ball actually be thrown all different random direction. It sometimes being thrown upward, or off centre of where character is facing. Below is a video that I made myself. How can I fix that?

Video
 

Andrew

Moderator
Staff member
So you want the throw direction to be random, right? You could try sub-classing ThrowableItem, and at the beginning of StartThrow, set m_Velocity to a Vector3 filled with random amounts.

C#:
protected override void StartThrow()
{
    m_Velocity = new Vector3(Random.Range(-5f, 5f), Random.Range(-5f, 5f), Random.Range(-5f, 5f));

    base.StartThrow();
}
 

dereklam0528

New member
Hi,

After I solved the issue. I am facing another issue. I am swapping the animation from the one I have got from Asset Store. I have got the animation event implemented etc. However, the item is thrown at an angle (side way) and I don't know why. You can watch the video to get more info.

 

Andrew

Moderator
Staff member
The thrown object gets instantiated at the "Throw Location" transform in the rig (set in the First/Third Person Throwable Item Properties components) when thrown, so I'm guessing that your new animation moves the character's hand (or wherever the Throw Location is) to be pointing at an offset angle at the moment when the throw occurs. You'd probably need to take a look at the rig during a preview of that animation at the point when the event is called and see if the transform is at an angle.
 
Top