Another Fps :)

Hi,
As a bit of a learning process for myself I’m creating a very simple FPS.

My goal is to have one or two small rooms, with a couple of enemies with simple AI.
I’m more of an art guy than a programmer, so I’ve learnt a lot from fps tutorials and python scripts (such as a bunch of different mouselook scripts that are floating around the internet), but so far all the art is placeholder, whilst I work out how everything works.

Without further ado, I’ll post the .blendhttp://uploader.polorix.net//files/1448/version1.blend

and some screenies
http://uploader.polorix.net//files/1448/screen1.jpg
http://uploader.polorix.net//files/1448/screen2.jpg

(use the mouse to aim, the left mouse button to fire, and the right mouse button to aim using the scope.)

I have a few problems that I can’t see a fix for myself.

The first is that I’m having trouble getting the recoil animation to play properly.

Ideally what would happen is that it would start the animation from the beginning every time a bullet is fired, however just now it plays through the full 10 frames before starting again.
If I could have it restart locally,e.g, the animation plays to frame 4, i fire another bullet, the animation starts from the position it was left in at frame 4, and plays again until I fire another bullet.
This would mean that the recoil would be additive, meaning that the more bullets you fired, the higher you would be aiming.

There is also a problem with the bullet velocity.

Right now the bullets use linV to push them forward, however they are quite slow, as when I use high values (pecuilarly, anything over 279) they cease to affect the targets.

Also, if I only fire 1 bullet, it does not affect the targets, they only move when I fire a burst of two or more, and I do not know why this is.

I think these problems are related, and I get the feeling I shouldn’t be using linV for this.

Thanks for looking.

Hey nice start,

About the bullet velocity, most people use rays to handle checking bullet collision. I like to put the ray sensor on the bullet itself, and move the bullet with a high linV. The ray length is a little bigger than the bullets distance traveled per frame, so it will always register a hit.

B3D00 has a great bullethole script. One of the best features is that when the ray is positive it adds an object at the hit location to simulate the impact force.

Good luck!

Hi,

thanks for the help, but could you please explain the ray stuff in a bit more depth, or point me in the direction of a tutorial for it?

Ray sensors (Or “ray picking”, “ray casting” or “ray testing”) is a common operation in game engines which takes a position and a direction, casts a ray along that direction, and returns the position and other applicable data about where it hits.

In Blender, the “Ray” sensor brick, for objects, can be used to detect objects within a certain distance, along a ray shot from one of the primary axises (x,y,z, or -x, -y, -z).

The reason the bullets don’t affect the targets is because the operation which tests for collisions on them doesn’t check the space inbetween the bullet’s positions each frame. The term for this is “discrete collision detection”. Systems which do check the space inbetween (at the cost of CPU power) have so-called CCD, or “constant collision detection”.

Ray sensors are a cheap way to avoid this issue with tiny projectiles like bullets.

I’ve been modelling a holographic sight, but I have a problem.

http://uploader.polorix.net//files/1448/eotech1.jpg

You see, the holographic sight works by collimating light from a laser, so that the target reticle always points the correct way, no matter what angle you look at it from.

Now, the easiest way to simulate this would be simply to place a reticle out in space in front of the sight, however you can then see it without even looking through the sight.

Does anyone know if it is possible to make something visible only when seen through another transparent object?
Alternatively, does anyone have any better ideas to simulate it in the game engine?