- Home /
How do I make my character "throw" and "catch" an object?
In my game, I have the player - and hopefully with some learning - other players throw and catch an object to each other. I am familiar with the basics (and a bit more) of javascript, but am only somewhat fluent in unityscript. Please leave code in unityscript as it is the most similar to what I am knowledgeable of.
P.S. This is in Unity 2D so I need code (If that is what you are providing) that is compatible in unity 2D.
Thanks in advance.
FYI: Unity 2D does not exist. When you run unity in 2D it simply sets up an orthographic camera. Physics ignores the Z direction. Everything else is the same.
Answer by fafase · May 15, 2014 at 04:56 AM
You throw using AddForce, you catch using a trigger box placed in front of the character and when the object enters the trigger, you parent it to the character at the hand position or wherever you want it to be.
While throwing you also unparent since the object was properly attached to the thrower.
The terms I am using should get you on the path of Google, search parent, AddForce and you will have fully working example available.
Your answer
Follow this Question
Related Questions
Please help with this code!! 1 Answer
JS file deleting multiple game objects 0 Answers
setup a php master server 2 Answers
Combo Script Problem 1 Answer
Teleporting from one scene to another and back again with the same player gameobject 1 Answer