So I was wondering how to make arrows (like bow & arrow) in BGE. After some thinking, I came to a solution.
First, turn on physics for your arrow. Then when you create it, you can give it a starting velocity and such.
Then write a short python script that makes it point in the direction it’s traveling, hook that script up to an always sensor, no actuators. Here’s mine (still a bit of a noob at scripting, so it’s not the best, but it works):
import bge import mathutils def main(): cont = bge.logic.getCurrentController() own = cont.owner vel = own.worldLinearVelocity print(vel) dir = vel.normalized() q = mathutils.Quaternion((0.0, 0.0, 0.0, 0.0)) q = dir.to_track_quat('Y', 'Z') print(q) mat = q.to_matrix() print(mat ) own.worldOrientation = mat print(own.worldOrientation) main()
You’re welcome, attached is the test file.
arrow_test.blend (350 KB)