|
1 registered members (qin),
7,805
guests, and 2
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Few questions about bullet impact.
#212144
06/20/08 17:01
06/20/08 17:01
|
Joined: Jul 2005
Posts: 262 Earth, The Netherlands
NL_3DGS_n00b
OP
Member
|
OP
Member
Joined: Jul 2005
Posts: 262
Earth, The Netherlands
|
Hi, In my test project, I'm creating a 1st person shooter script. Shooting works, changing gun too, and also have a script that creates a bullethole on the walls. This is the scripts that creates the bullethole: function display_hithole(){
vec_to_angle (my.pan, normal); // orient the hit hole sprite correctly
vec_add(my.x, normal.x); // move the sprite a bit away from the wall
set (my, PASSABLE); // the hit hole bitmap is passable
//set (my, TRANSLUCENT); // and transparent
my.ambient = 100;
//my.roll = random(360); // and has a random roll angle (looks nicer this way)
my.scale_x = 0.5; // we scale it down
my.scale_y = my.scale_x; // on the x and y axis
wait (-30); // show the hit hole for 20 seconds
ent_remove (my); // and then remove it
}My questions: 1. How can I make bulletholes also appear on models, like barrels, lights etc.? 2. How can I detect what kind of surface the object is? (Glass, wood, brick, concrete etc.) So I can use different bullethole images. 3. Is there a way to make some wood shatters drop down and disappear when I fire at a wooden crate or something? (So it looks more realistic when I fire at it) 4. How can I make the gun "spray" a bit. I mean, now it fires directly at one point, and bulletholes overlaps eachother perfectly, I want to be able to change the accuracy of the weapon. Thanks. Those are my questions. (For now :P)
The best games are the games you create yourself.
|
|
|
Re: Few questions about bullet impact.
[Re: NL_3DGS_n00b]
#212308
06/21/08 14:32
06/21/08 14:32
|
Joined: Oct 2004
Posts: 4,134 Netherlands
Joozey
Expert
|
Expert
Joined: Oct 2004
Posts: 4,134
Netherlands
|
1. How can I make bulletholes also appear on models, like barrels, lights etc.? I think this problem is related to your shooting code if you can't hit the models either. Can you shoot and hit models and is just the bullethole not appearing? Then it might be the 'normal' variable that does not have a right value. 2. How can I detect what kind of surface the object is? (Glass, wood, brick, concrete etc.) So I can use different bullethole images. Tricky question and there are some complex solutions, and some less complex solutions. You can detect a whole model's surface type, or the model's skin for a surface type. I'd suggest to check for a whole model first, and then try to figure out how to detect certain material on the skin of the model where you hit. For checking the whole model, just define a few surface types like:
#define 1, _SURFACE_METAL
#define 2, _SURFACE_GLASS
#define 3, _SURFACE_BRICK
Then give the model's skill a surface type from one of the defined materials:
...
barrel.skill12 = _SURFACE_METAL;
...
window,skill8 = _SURFACE_GLASS;
When you hit the model, and place the bullethole, just check skill8 of the hit entity, make a switch for all the different materials and you're set:
switch(hit_entity.skill8) {
case _SURFACE_METAL:
my.skin = 1;
break;
case _SURFACE_GLASS:
my.skin = 2;
break;
case _SURFACE_BRICK:
my.skin = 3;
break;
}
You could align the "material's definition numbers" with the "model's skin numbers", but it could also mess up, so whatever you prefer. This solution only needs the following code:
my.skin = hit_entity.skill8;
3. Is there a way to make some wood shatters drop down and disappear when I fire at a wooden crate or something? (So it looks more realistic when I fire at it) You can try particles using effect() or create bitmaps using bmap_create(), or create models of several wood shatters using ent_create(). I'd go for the effect() function but it requires alot of tweaking. ent_create is the easiest solution. 4. How can I make the gun "spray" a bit. I mean, now it fires directly at one point, and bulletholes overlaps eachother perfectly, I want to be able to change the accuracy of the weapon. That is also related to your shooting function. Just add some random values to the shooting direction using random(x*2)-(x) where x is the amount of deviation. So when x=40 (with a chance of 40 degrees deviation) You'd get random(80)-40, resulting in a shooting range of -40 to 40 degrees.
Click and join the 3dgs irc community! Room: #3dgs
|
|
|
Re: Few questions about bullet impact.
[Re: Joozey]
#212323
06/21/08 15:35
06/21/08 15:35
|
Joined: Jul 2005
Posts: 262 Earth, The Netherlands
NL_3DGS_n00b
OP
Member
|
OP
Member
Joined: Jul 2005
Posts: 262
Earth, The Netherlands
|
Thank you very much. (Mede hollander :P, vanavond gaat Nederland winnen, altans, hoop ik :P)
About that detecting the surface, about that my.skin part, are you talking about the skin from the bullethole?
However, before I can start with surface detection, I have to make it possible to fire at entities. Could you take a look at my display_hithole function? Maybe you can see why I can't shoot on models...
The best games are the games you create yourself.
|
|
|
Re: Few questions about bullet impact.
[Re: NL_3DGS_n00b]
#212341
06/21/08 17:04
06/21/08 17:04
|
Joined: Oct 2004
Posts: 4,134 Netherlands
Joozey
Expert
|
Expert
Joined: Oct 2004
Posts: 4,134
Netherlands
|
Rusland gaat eraan geloven  About that detecting the surface, about that my.skin part, are you talking about the skin from the bullethole? yeah, I forgot you aren't using a model but a sprite. So replace that my.skin with an ent_create function or something, i.e. I hope you get the basic method I explained  . I don't have your "bullet creator" function so I don't know precisely what you did. However, before I can start with surface detection, I have to make it possible to fire at entities. Can you verify that you do hit the models (so they lose health when you hit them), but only the bullethole does not show up? If this is not the case, then the problem could be in your shooting code rather than in your display_hithole code. If you can hit the model but only the bullethole wont appear, then try to make the bullethole clearly visible in one place, so you are sure that it is created or not. The problem could be related to the 'normal' variable, but I'm not sure.
Last edited by Joozey; 06/21/08 17:07.
Click and join the 3dgs irc community! Room: #3dgs
|
|
|
|