GE: Ray help for FPS

Hi, I am making a mini FPS game to teach myself about rays.

As of now I have a ray from my player, when the enemy (cube) is within the ray and the mouse is clicked, the player sends a message to the cube telling it to die, this works but it’s not what I want. I made a HUD scene with crosshairs, ideally I want the crosshairs to cast a ray so only objects in the crosshair can ‘die’ instead of in the ray of the player- how can I do this (I already tried parenting)? Please look at the blend file as I use my custom way of turning using the mouse and WSAD. Thanks in advance for any help.

Download .blend, its mediafire because BlenderArtists won’t let me upload, sorry.

Let the Camera cast the Ray.

But will that be the size of the crosshairs? And thanks.

If you use one Ray it will always be the Size of a Point. Rays do not have a Diameter: For that you would have to use a Radar, that would suit the Case perfectly. However, the Logic is heavier and in the End it might make little Difference. If your Crosshair is a Circle, then it might make Sense, but if it is indeed a Cross, then a Ray would be enough. (If the Weapon is a Shotgun, however, you really have to take use Radar. :wink: )

Thanks C.A.ligari, so, how do I make this ‘point’ bigger/smaller? Thanks for the help :slight_smile:

EDIT: I can’t get the camera to work using the ray - I don’t know why :(.

As said, I at least don’t think the Point can be resized. If someone outthere knows that and how it is possible, I hope they show up here and prove me wrong, but from what I know a Ray is just a Line, a mere Line, no Cylinder.
And I guess when you let the Gun or the Player cast the Ray, you probably cast it on the Y (or X) Axis. However, in Case of a Camera the Direction which the Camera is looking is always the Z-Axis (as a Camera with 0,0,0-Rotation points down as well).

Removed video, Monster helped (thank you!).

apply scale to all parents!

Ah thanks Monster :slight_smile:

Im still having troubles, now I have this setup,
http://imageshack.us/f/35/picture1emr.png/ Link broken… http://imageshack.us/photo/my-images/35/picture1emr.png/
But it’s not working, anyone know why? :frowning:
The plane is very small and in the camera but the ray only casts a small line so it shouldn’t matter?

What is the Plane actually for? Because in the first Place it sounded to me as if you already had some Crosshairs, so I wouldn’t guess that the Plane is supposed to be one – even though it makes Sense to try out different Possibilities. But if that Plane just bugs around, then you may as well just not use it. You have working Crosshairs in your Foreground Scene and the Ray can be casted from the Camera on the Z-Axis. No Need for that Plane then. Except it is meant for something else?

Yeah, the crosshairs are on an overlay scene so they were out of the question. I did solve this though, I used the camera like you suggested and it worked… but not immediately. I just got the axis mixed up (from the players angle it’s -Z Axis for the camera.
Thanks for the help. :slight_smile: