simple question about objects

I made a first person shooter. but the bullet goes so fast that it goes straight through the enemy. And it doesnt detect the collision. is there any way i can increase a value or something that will make it so this doesnt happen? Any help is much appriciated.

Nope nothing that’ll give you good results all the time.

Best thing is to use the ray.getHitObject that’s casted by the ray from your shooting cursor. Since it’s a FPS I’m guessing you have a AIMER thing. Have a ray sensor for that and increase it’s range limit so you can detect far away.

You’ll need python. Considering you got the ray sensor hooked up correctly, this would be all you need to do.

Make a ray sensor that detects the property “enemy”. Make sure this property is only assigned to your enemy characters. Necessary cause you’ll need to set a property “dead” on the enemy. This will replace that collision that’s needed so the enemy knows he’s hit.

The enemy property “dead” is only set to true here when the AIMER ray detects the enemy and left button is clicked (when you shoot).


import GameLogic as g
c = g.getCurrentController()
o = c.getOwner()

lb = c.getSensor("leftbutton")

ray = c.getSensor("ray")

if lb.isPositive() and ray.isPositive():
    rayOB = ray.getHitObject()
    rayOB.dead = 1

If you know python you can extend this further.

Jason Lin

uhh actually all i have is a bullet that is spawned at the tip of the gun when you hit the shoot button, and is shot forward at all times. Then all the bad guys are set to end mesh when collided with the bullet. Then also add mesh to an explosion.

lol, goldentaiji, i think i am just going to follow you around from now on, collecting various choice bits of script as i go. :stuck_out_tongue:

:o Modron following me around.

Yeah, Stella that’s what I was hinting at. Your current setup won’t work all the time (ie: your bullet going through the player). I was suggesting you add the extra stuff I said on top. Well like the saying goes “a picture is worth a thousand words”, I guess a .blend is worth that much too. Here’s an example .blend of what I said up there.

Hmm, slightly modified version of the look around file TankC gave me awhile back. Just modified it to include the stuff you would need to setup in your .blend. Here you go http://antihc3.dyndns.org/blender3dsite/uploads/MISC/target_select.blend

:wink: Included a small explanation as well.

Jason Lin

hahawww man i wish i new how to use python danng.
id like to use the mouse control in my fps, that would be awsome.

Good games are complex games. Python lets you add complexity. A simple code piece can eliminate 10 logic blocks, while making it easier to debug.