Arrow Physics

<cite>@reveance said:</cite> I'm pretty sure that you have to create a custom Control (https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:custom_controls) in which you add the behaviour of the arrow (also put all the physics related stuff in there). Those controls are hooked into the main update loop. Create a new instance of the control and add it to the Spatial, that way the behaviour will be individual for each arrow fired.
But I already added rigid body control to it.
<cite>@koljo45 said:</cite> But I already added rigid body control to it.
You can add more than one control to a spatial.
1 Like

Did it, but again need help. First time I failed to mention one thing. When I add rigid body control to the arrow spatial I cant rotate it via arrow.setLocalRotation(ā€¦), or anithing else for that mater, but I can go arrowRigidBodyControl.setPhysicsRotation(ā€¦). So I created custom control and every time I add that control to arrow I have to use arrowRigidBodyControl to rotate it in my custom control, I cant use spatial.setLocalRotation(ā€¦). And when I fire more arrows lag becomes higher and later arrows just fall thru the floor. So do i need to add colision detection to the custom control and when they hit something somehow stop them, maybe set arrowRigidBodyControl to kinematic(when I set it to kinematic arrow freezes).

Ok, just solved lag problem, but some arrows still fall thru, but no lag. It seems I had too mutch to console output(I didnt even know that too mutch to console output can create lag :-o ), but still have issues I addressed before.

The console is probably one of the slowest things if you use much outputs as it needs to synchronize for a ordered output.

For the tunneling three solutions
-> Make the arrow collision larger/longer
-> enable CCD in the collisionshape in case of using native bullet (it does a sweep test if it moves fast)
-> manually do the second, do a ray test for the approximate move in the next tick, and slow it doen exaclty before it should collide, so it does not tunnel.

Does anyone have an idea on how to make arrows stop when they hit a target? I used PhysicsCollisionListener before, but dont know how to stop the arrow. Is there a method in RigidBodyControl I can call? And also I wanted to ask about arrows in other games. I noticed when you shoot certain number of arrows old arrows start disappering, why is this?

I thought of removing rigid body control when it hits, well it works but it crashes. That is sometimes I manage to make first fired arrow to stay by removing rigid body control, but when second hits game crashes.

<cite>@koljo45 said:</cite> I thought of removing rigid body control when it hits, well it works but it crashes. That is sometimes I manage to make first fired arrow to stay by removing rigid body control, but when second hits game crashes.
I haven't done enough with physics to know how to do this properly, however giving the arrow a mass of 0 shouldmake it stop moving.