Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Help Needed. I can't Shoot!

Author
Message
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 24th Aug 2005 01:53
It's my turn to ask for help this time!

I've been toying around with making a tutorial on generating landscapes and AI in DBC and thought I'd combine them and make a demo program to go with the tutorial.

So, I knocked together the demo which generates it's own matrix and has cubes wandering around.

Anyway, to cut a long story short, half way though doing the demo, I thought it would make a nice basic, but fun game - rather than just a demo if some of the cubes were red - the enemy - and you tracked them down and took them out with a sniper rifle - before they got you.

At this point, I discovered that I haven't got a damn clue how to shoot!

I played a long time ago, but I ended up with either invisible bullets or they looked like 'bullet time' in Max Payne and the target had long since gone before the bullet actually got there!

And then there's detecting if the bullet hit the target...

I'm sure there will be posts on the forum to help me with that side of things, so I guess I can sort that out.

What I can't sort out though is replacements for my cube placeholders which wander about. Is there anyone out there who can do for me, (or has already got that they can spare), any .X models please?

I'd like it to look fairly reasonable and look like a soldier (any kind really) with animations for a) walking around pointing a gun, b) dropping dead (when shot) and c) a stance for firing when he spots you.

Not being able to do this myself, I'm afraid I don't know really how massive a task that actually is for someone who knows what they are doing.

If it's not that difficult, the same model textured in civilian clothing would be really useful too. Without the gun of course...

Full billing in the program for anyone who can help out - naturally.

Here's a link to what I've done so far. Not a lot as I only started a few hours ago, so there are a few glitches.

http://www.computechtenerife.com/sniper.rar (1.1MB).

Here's hoping the post isn't locked now for looking like a team request! I don't want a team btw - just help with the models.

Thanks...

TDK_Man

NanoBrain
20
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 24th Aug 2005 06:28
TDK,

About shooting bullets, I only use raycasting as "the bullet". That is, unless the object needs to be seen, like a grenade thrown or some other bulky weapon form.

Since bullets fired from a pistol or other highspeed weapon, move so fast, there is no need to see them. Therefore, no need to use an object in its place. Also, in the size of any game arena, to the extent of largescale outside environments, you could say that a buller virtually reaches its destination, once shot, in the next frame of the game. However, this timing is easily adjustable, by the distance you set a raycast to check in one frame.

I am not sure if you have used any type of raycasting or not, but I will try to simply explain. There are technically only three major necessities in raycasting. A start point, an end point(bullet travel distance) and the angle the bullet is traveling. You can literally name a casted ray, a vector. That, several points are checked on this line, from its start to its end, the distance between each point checked, defined by the programmer and how accurate he wishes the check to be. The more accurate though, the more processing power needed, unfortunately.

In Psuedo order, when the user presses the "fire" button, first a few values should be recorded. The player's position, angle(for an fps, two angles would need to be recorded of two axies), and the distance the bullet can ultimately travel. In the example below, I simply record only one angle, the y axis angle, only enabling the bullet to fly on a horizontal plain.

Example:


Now we have recorded all the necessary values to create the raycasting. If one can move an object in 3D space, using newvalues or cos and sin, then he can also create a casted ray. Raycasting is literally like moving an object from one point to the other, at step values, from a beginning point to a specified ending point. However, with only using coordinate values and not an object(unless necessary for collision checking), and all in one program loop. The movement is completed some finite loop, which is nested inside the program loop. Therefore, every point can be checked for collision in the blink of an eye.

Now, to check specified points(evenly spaced points) from start to finnish on this line. Let us say we will use the code above, and the bullet can travel 200 units max. Therefore, 0 is our start point, and 200 is our end unit. The last position checked by the ray will be 200 units away from the player, in the direction recorded. In the example below, we use an accuracy of 1 unit space gap checking. Therefore, the distance of the check will be incremented by one every raycast loop.

Example:


This is the very basics, that you might already know. However, when I have some more time, I will go into more detail. Getting into the subjects of delay in firing, rapid fire, single fire, sounds, ammo decrementing, etc. Hope this will get you somewhere for now.


+NanoBrain+
NanoBrain
20
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 24th Aug 2005 06:28 Edited at: 24th Aug 2005 06:29
[EDIT]Whoops. Accidental double-post.


+NanoBrain+
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 24th Aug 2005 06:39
Yes it does thank you.

It hadn't occurred to me that you shouldn't actually see the bullet!

In the past, that's where I have been going wrong. I have been making the bullet slow enough to see - which of course is too slow.

TDK_Man

Login to post a reply

Server time is: 2025-05-22 12:57:12
Your offset time is: 2025-05-22 12:57:12