Hipfire problem

Hey guys,

I’m right at the moment developing a fps and i’m struggling with the hip. how can the gun shoot straight if it’s hold straight? And i want the shoot come out of my gun and not be an ray in the middle of the camera, especially for laser weapons or so. I mean the weapon reticle alsways is in the middle of the screen and the shot goes “there”, it doesn’t matter if the target is 100 or 10 feet. But does that work?

Neither do I know what that has got to do with any Hips nor what you even mean by Shootin’ straight – or at least, I don’t understand the Problem.

But you can change the Logic Bricks or the Python Script that generates the Ray so that the Ray is not shot by the Camera but by the Weapon itself – though of Course it is rather practical for the Player if the shot actually hits what is within the Reticle.

EDIT: You sound as if you were using a predefined FPS Setup which you have not yet dissected or truly understood. Dig into it. ;}

No i’m not using a predefined FPS setup. And sorry I meant i’m struggling with the hip fire. :o I feared that nobody would understand the problem because it’s quite wired. I know how to use rays, but I want the player to see the shoot, for slower weapons like laser etc. That’s why the shot has to be added with an empty in fornt of the gun. Well I know all of that, but let’s get back to my problem: I’ll quckliy make a drawing, that explains the problem.

If you have a ray coming out of the camera, when it collides with a possible target it returns hit point.
Move an empty to hit point and get the weapon to track to it.

*** In essence there could be an obstacle in-between gun and target unseen by main targeting.

What rarebit says. Great Idea, Dude! :}

To explain the problem: Firing a gun “from the hip” means to pull the trigger when the weapon stock is resting on or floating close to the hip. This implies a lack of accurate aiming, but it means you can run around while shooting…

sumie wants the “hip firing” technique to hit what you are aiming at…impossible without a gun pointing through the body, or a gun that can focus on targets close or distant.

Yes, I agree with rarebit, but I wanted to

Thanks for the Ideas, but I don’t get excactly what you mean or only somehow, and i have no idea how to do it. Could you please explain it a little more, or even make a little tutorial. Would be grate. Would that work if you are running around and the targets, enemies are also moving. I don’t get that. :frowning:

@Looks like you didn’t finish what you wanted to say.

“hip shoot” = Rambo fire = a method to shoot holes in the air assuming everything around you is a target ;).

Try this Demo. It shows you how to use the S2A to set a target under the mouse cursor.
The guns are tracking this target.

You can use this method in combination with ray sensors too (instead of mouse over).


TargettingDemo.blend (56.3 KB)

Hey cool, many thanks for the great help, but because i suck at scripting, i have no idea how to change the mouse over to the collision of a the ray. Could you please help me with that?

Try this one.

The camera sends a ray along -Y.


TargettingDemoII.blend (55.7 KB)

I don’t get what you are trying to explain to me with targettingDemoII.blend.

Is it fully working?

Sure, it works.

The “aiming”-ray is emitted from the camera straight forward.
Where it hit the little sphere is placed.
Which is the target of the guns.
It is a bit difficult to notice when you look through the camera. Simply watch it until it made a 180 degree turn.

How you move the camera is up to you ;).

I was away for a few days nad didn’t have time to work on it, but now I tried it and still have a problem: What’s is a python module, how can I move it to another blend file, where to find it, how to edit and that kinda stuff. I already set uo the camera movement, with a little gun and a bullethole script and a few animation so I wanted to import and use it there. I’m sure that’s possible but how?

a Pythom module is a text file with Python code. The extention is .py.

Usage in Python:
Python controller module mode. Enter moduleName.functionName

So, did yu do this module youreself or is it automatically installed with blender? And are you really sure that it works, because i moved the camera to another position, but the guns still shoot to the same point. Oh yes it works, just had to clear out the parent.

Make sure there is something in the middle of the screen. Otherwise the target (represented by the little white sphere) remains at the last position.
The cameras simply parent was added to make the camera move ;).

Yes, you write your Python code by yourself. Or you use it from someone else. Just check the Text view.

Oh, yes of course, when I appended the scene to my file, the text were gone (I cuoldn’t open them in the text editor but now I can.) But if there has to be something in the middle of the screen can I still use it for an fps and will it make the bullets fly to the median point, because then there have to be some changes. :frowning:

Ah ok you wanted to append or link. In that case you need one Python controller (in script mode) with the name of the textfile. Do not connect it to any sensor/actuator.

This controller will act as “script holder”. It forces Blender to append/link the text block with the game object (similar to materials).

Where should the aiming target placed to if there is nothing to find?

Ah, okay. The aiming target should be just so the the bullet flies straight forward, but there usually is alawys somehing just very far away, a wall or what ever. And the bullet should simply hit the target there were the ray hits hit. So if there is a wall which is 20 meters long it shoulnd’t fly to the median point, as I think it did before, but excatly there were the ray hits the wall.

Edit: Sorry i just found out that this isn’t the case… Is it defined in your script, how far the bullets fly, because so far, I simplay did it with add object, in this case bullet, at an empty and defined where and how fast it flies. Does my gun or the empty have to have a specific name to be recognized from the script, because AimingGun nowhere appears in the script. And how can you define how far the camera can see?

So I was jsut doing some progress on my fpsadding a gun, recoil animation etc. But I’m having prblems with the gun. somewhy it suddenly changes position. Not from time to time, but it’s not there were it’s supposed to be. I already set it to ghost, so it’s not interferring with the player, still a box, but still the same problem. To make the aiming animation work, I created a boy around, made it invisible and parented the gun to it. This has worked, before, but not now?? Why? I’ll append the blend file, so you can have a look. Somewhy I can’t attach it, so i’ll upload it to megaupload: http://www.megaupload.com/?d=NTWVM5M4

Monster, you have an iron determination to help–you’re awesome.

Sumie, take it slowly-if this is your first project on this scale, I can only counsel patience. Feel free to use another blend file to experiment, or have a copy to mess around with.

You’ll get it, and when you do, you will have massive bragging rights to your friends.