Arrows

i'm trying to do arrows(like those that are used with a bow), but, i don't know how to do them.

my actual code is something like this

Code:
      private function correct():void {
           var velocidad:b2Vec2 = b2body.GetLinearVelocity();
         var angulo:Number= Math.atan2( velocidad.y, velocidad.x )
         b2body.SetXForm(b2body.GetPosition(), angulo);   
         }

this is called every frame.
however, is highly innacurate.

i tryed searching, but all the matches seemed to point to keyboard arrows, perhaps i didn't search well.

can someone give me some example working code, or at least some tips on how to do this?
thanks you very much :3

and, also, sorry my bad english.
Well it looks like you are doing what you should do, what do you mean by "highly inaccurate" ?
Hm, what's that??
well, at first sight it looks ok, but, you know, i am using box2d, what i have right now i could have done it without box2d, i mean, i feel that perhaps using forces or torques it could be done better, but i don't have a clue of how a "real arrow" should move, friction, gravity, etc.

i'm asking for some help for that.

also.

Quote:
Hm, what's that??

i'm trying to do a function that would make an arrow that looks real.
however, my actual function, only makes the arrow look like it is being dragged around.

----------------

thank you for the responses.
if someone have some clue, please, tell me 😉
The motion of arrows is due to aerodynamics. Box2D cannot help much.
You should either fake it (such as you are doing above), or try applying appropriate forces.
hey boris
in water demo if i play with offsets and make it appear like sine wave so can i produce waves...
Your arrow must be made of several parts:
1. Arrow head
2. Arrow stick
3. ...
Use really high density for your arrow head and some really small density for your arrow stick! 😉
If you want to shoot it - apply force ONCE to your arrow head 😀
Neosano wrote:
Your arrow must be made of several parts:
1. Arrow head
2. Arrow stick
3. ...
Use really high density for your arrow head and some really small density for your arrow stick! 😉
If you want to shoot it - apply force ONCE to your arrow head 😀


This would not work. Heavier objects don't fall to the ground faster than light ones. Further, how do you propose these parts are connected?
android wrote:
Neosano wrote:
Your arrow must be made of several parts:
1. Arrow head
2. Arrow stick
3. ...
Use really high density for your arrow head and some really small density for your arrow stick! 😉
If you want to shoot it - apply force ONCE to your arrow head 😀


This would not work. Heavier objects don't fall to the ground faster than light ones. Further, how do you propose these parts are connected?


Uhm,erm... I was talking about the shapes, arrow head shape must be heavier. It will rotate, fly, fall realistically.. I guess..
Neosano wrote:
Uhm,erm... I was talking about the shapes, arrow head shape must be heavier. It will rotate, fly, fall realistically.. I guess..


Sorry to disappoint. 🙂

You could simulate aerodynamics (the tail of an arrow having a higher drag), by connecting two bodies with an appropriate joint. Then you can set the linearDamping of the 'tail' body to a higher value. I just experimented with this, it kind of works, but results tend to be instable.

Original thread: https://box2d.org/forum/viewtopic.php?t=3091