FPS gun shoots crooked

I made a fps game, and it works fine except the gun shoots crooked after you rotate the camera more than about 45 degrees.
I have the Add Object actuator set on local, fyi

any suggestions?

A friend of mine added shooting to my tankgame and then it started to get crooked until about 50-60 degrees and then aims in the direction it should (almost).

Hrm. . . Nice job on actually following through and creating the game. Hurrah! I suppose the problem may be that the empty may not be far away enough from the muzzle of the gun or perhaps the bullet’s scaling and rotation aren’t applied (that may cause some troubles).

how do u apply the bullet’s rotation and scaling?

i have the empty right at the muzzle, is that a problem?

Yeah, eyes in blender, thats my problem!

Try moving the empty a little farther out, it could be the object added initially overlaps the muzzle of the gun and screws its direction.

yeah i had that same problem : / and hi guyz (and any girlz out ther) im back again (finally) :smiley:
man its been a long time…

Thenx, but that didnt work

I’ll try to find a solotion and maybe an answer to why this happens…

if you make any setup with emptys and objects being fired from them you allways seem to get a problem. I friend of mine has the same problem. I would if I were you use socials FPS template and take the gun setup from that.

You’ll better use ray sensors for guns. Here’s a simple script, it may not work, I had never tested it. Or just copy the bforce script from social’s fps template.

import GameLogic as GL

cont = GL.getCurrentController()

fire = cont.getSensor("lmb")
ray_shoot = cont.getSensor("ray_shoot")
add_force = cont.getActuator("add_force")
force = add_force.getLastCreatedObject()
ray_position = ray_shoot.getHitPosition()

# add_force just adds a invisible cube that depending to what it collides, it adds a
# spark or bloodsplat effect.

add = fire.isPositive() and ray_shoot.isPositive()
if add:
    GL.addActiveActuator(add_force, 1)
    force.setPosition(ray_position)

Basically you just have to change some object names. And add a ray sensor pointing to the front.

I had the same problem, and solved it using rays.

I posted the only solution i’ve ever found for that problem in another thread a couple days ago. It’s some where in this forum, just use the search function. This problem occurs a lot when you parent emptys that add objects. You’re better off learning python or trying to make a differen’t type of game.

If your objects do not have cleared origin and rotation and stuff, then crooked problems can occur, such as the child object going wonky when the parent rotates or moves. Unparent your objects, then clear rotation with alt+r, and hit alt+g, and what the hell, throw some alt-o in there for good measure.

Know it’s some time since this thread was new, but however, the problem seems to be solved with the new 2.47 version. I have both 2.45 and 2.47 and I compared exactly the same file (created in 2.45) in both and the diffences were: my computer was faster in the 2.47 and the problem with the crooked shooting didn’t exist there either.