Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
0 registered members (), 16,643 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
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 Offline OP
Member
NL_3DGS_n00b  Offline 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:

Code:
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] #212281
06/21/08 10:53
06/21/08 10:53
Joined: Jul 2005
Posts: 262
Earth, The Netherlands
NL_3DGS_n00b Offline OP
Member
NL_3DGS_n00b  Offline OP
Member

Joined: Jul 2005
Posts: 262
Earth, The Netherlands
Anyone?


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 Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
Quote:
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.


Quote:
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:
Code:
#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:
Code:
...
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:
Code:
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:
Code:
my.skin = hit_entity.skill8;



Quote:
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.


Quote:
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 Offline OP
Member
NL_3DGS_n00b  Offline 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 Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
Rusland gaat eraan geloven laugh

Quote:
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 smile. I don't have your "bullet creator" function so I don't know precisely what you did.

Quote:
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
Re: Few questions about bullet impact. [Re: Joozey] #234153
11/01/08 10:45
11/01/08 10:45
Joined: Sep 2007
Posts: 52
Tver,Russia
D
dtntr Offline
Junior Member
dtntr  Offline
Junior Member
D

Joined: Sep 2007
Posts: 52
Tver,Russia
Hi guys. My wepon use bullets(no c_tace) for shoot. I use event_impact for dection collision with bullets. I check you entity skill15 to detrmine which surface hit my bullet. But i use multitexturing shader on terrain. How i can detrmine which surface hit my bullet on terrain. Thanks


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1