I think my question is pretty straightforward:
You have the player and some objects containing my own script “Throwable”. In my case beer bottles.
I already got the player to pick up those bottles and throw them. The center of the “InteractionPoint”(which is the white circle with the crossing diameters) is the position, where the bottles will be “held” once picked up.
My script looks like this:
public bool PickUp(GameObject attachedTo)
{
gameObject.transform.parent = attachedTo.transform; // Add to parent
gameObject.transform.localPosition = attachedTo.transform.Find("InteractionPoint").localPosition; // Set position
m_collisionpoints.enabled = false; // no collision
m_Rigidbody2D.isKinematic = true; // no gravity
m_Rigidbody2D.velocity = new Vector2(0f, 0f); // no velocity
m_Rigidbody2D.angularVelocity = 0f; // no rotation
PickedUp(true, attachedTo); // picked up and parent
return true;
}
That works and looks like this:
Now throwing isn’t too bad either, just revert those manipulations done on the RigidBody and add a force to it, which also works fine. But I also want the player to be able to strike with the bottle. Maybe hold it upside down and attack with it. And this is where my problem lies: I have no idea how to tackle that idea.
Suppose we have a 2d animated frame-by-frame sprite and the interaction point is basically his “hand”. I don’t know where to start. Should it be an animation? Should I just script the InteractionPoint moving somewhere? How can I “swing” the bottle? As is it looks rather static, being fixed to the interaction point.