- Home /
Add force to an arrow
i want to create something like this
http://www.youtube.com/watch?v=k71-TKHZmYE (after 25 sec)
i can calculate the length of the swipe,and the position on the screen where the swipe started and ended but i am not able to add force to the arrow(which is Instantiated at run time),such that it gives me a proper feel of how a arrow is fired.
the code i am currently using to add force is
code#
if(fire) {
rigidbody.useGravity = true; rigidbody.velocity = Vector3(fireforce,fireangle,0.0); // i know rigidbody.addforce would have been a better option but it was not giving me the desired results }
// here fireforce and fireangle are the lenth of the swipe,and the y pos of point where the swipe ended respectively,as the point where the swipe will end will determine the angle and the length of the swipe will determine the force with which the arrow is to be fired.
can someone please help me out with this thanks in advance
Do not post on both sites, especially if you don't provide cross-links. Also, use the code button here.
Answer by watercat · Apr 16, 2018 at 07:07 PM
yor game is 3d or 2d this c or js
this coder is Vector3 which is here is 3d code if it has 2d colider or wat 2d i need Vector2 and rigidbody2d Gravity2d and so on
rigidbody.useGravity = true; rigidbody.velocity = Vector3(fireforce,fireangle,0.0); // i know rigidbody.addforce would have been a better option but it was not giving me the desired results }
Your answer
![](https://koobas.hobune.stream/wayback/20220613125148im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Bug? Need to wait about 10 seconds to get back to normal 1 Answer
Android Swipe In 3D World 1 Answer
Android Drag By Steps 0 Answers
Tap detection on Android 0 Answers
.NET System ticks on Android - what am I doing wrong? 0 Answers