Rick Posted April 20, 2011 Share Posted April 20, 2011 Well, I'll try to get threads going again So I had this up right before the site went down and I know mumbles had a lengthy post about it and not sure if anyone else had comments. My idea around this is making a square in the center of the screen that changes size based on running/walking/etc. Then when firing bullets find random x & y values inside this square area and cast a ray out from that point into the 3D world to see where the bullet would hit. Other thoughts/ideas on how people do this? Quote Link to comment Share on other sites More sharing options...
Aily Posted April 20, 2011 Share Posted April 20, 2011 First part is good, random point in square. But not raycast, better to use bullet body. set Pivot(dummy) target object on picked position b=Createsphere(.1) positionentity b,entityposition(player) ( or enemy ) pointentity b,target setbodygravitymode b,0 setbodymass b,1 septcollision b,1 ' important setbodyforce b,vec3(0,0,1000) setentitycollisioncallback b,on_bullet_hit,ENTITYCALLBACK_COLLISION First time i maked as you say, but then i was need to write separate code for enemy shots. In this issue enemy can shot just like player (you need just position it target to player) and respawn bullet. In my gameplay demo (with spaceship) bullets maked same. So you can control bullet size! Your fire from weapon will be respawn before respawned particles from hitted body. You can simple create ricochet with it Im using raycasting only for enemy finding player Quote "Better" is big enemy of "good" Link to comment Share on other sites More sharing options...
Rick Posted April 20, 2011 Author Share Posted April 20, 2011 So I seem to remember small bodies moving fast sometimes miss collisions. Are you finding that with this method? Quote Link to comment Share on other sites More sharing options...
Aily Posted April 20, 2011 Share Posted April 20, 2011 So I seem to remember small bodies moving fast sometimes miss collisions. Are you finding that with this method? SweptCollision body,mode - never miss Quote "Better" is big enemy of "good" Link to comment Share on other sites More sharing options...
Mumbles Posted April 20, 2011 Share Posted April 20, 2011 I gave you a response before the rollback, but since I wasn't sure if you were going to recreate the thread and if you'd even seen the response, I sent an email to your publicly listed address... Quote LE Version: 2.50 (Eventually) Link to comment Share on other sites More sharing options...
Ending Credits Posted April 22, 2011 Share Posted April 22, 2011 Linepicks seem a much quicker way of doing things, especially if you have a lot of bullets at once. Personally I use a firepivot which I rotate by a certain random offset dependant on the recoil and spawn the bullet there. Quote AMD Phenom 9850 (X4 2.5GHz) | 1066MHz CL5 GEIL Black Dragon (800MHz) | Powercolor ATI 4870 1GB | DFI 790FXB-M2RSH | 24" 1920x1200 | Windows Vista 64-bit Ultimate Link to comment Share on other sites More sharing options...
Flexman Posted April 22, 2011 Share Posted April 22, 2011 Linepicks seem a much quicker way of doing things, especially if you have a lot of bullets at once.Personally I use a firepivot which I rotate by a certain random offset dependant on the recoil and spawn the bullet there. That's pretty much what we did for the 30mm cannon on our helicopter. It does have a high rate of fire (one round every 96ms). With the new veg collision system I would see enormous FPS hits when opening fire, but the weird thing was that the terrain size of the map had a *huge* impact. Switching from a 2048 to 4096 sized map made a huge difference (bigger = faster) so there's some performance oddities with various map dimensions (regardless of tilesize). Picks can cause micro-stutter when it has to generate a collision shape for the first time too. Josh said he plans to change this to generate them at load time. For each shot fired from our Apache, a shell casing is spawned as a newton body, on the whole lots of newton bodies are hungrier than raycasts in our game (take out the raycasts and remove the casing limit and at around 50 shells the system begins to bog down). A limit of 15 body casings and 50 active raycast has far far less impact on our production map. It sort of depends how many you might have active at once and size of arena. Just offering experience of what I tried. *edit* I added a random off-axis value to the bullet spawn vector to generate some spread, I used the ammo count as a random seed since this should be consistent across a network game? Looking for better suggestions on how to do this. Quote 6600 2.4G / GTX 460 280.26 / 4GB Windows 7 Author: GROME Terrain Modeling for Unity, UDK, Ogre3D from PackT Tricubic Studios Ltd. ~ Combat Helo Link to comment Share on other sites More sharing options...
Mumbles Posted April 22, 2011 Share Posted April 22, 2011 For each shot fired from our Apache, a shell casing is spawned as a newton body, on the whole lots of newton bodies are hungrier than raycasts in our game (take out the raycasts and remove the casing limit and at around 50 shells the system begins to bog down). NewtonBody shell casings sound like overkill 9000. You're in the cockpit, how long are you going to see the casing for? Also is it imperative that people on the floor can see the casing fall and bounce accurately? Just an image may be a better idea, and for raycasts: 1 raycast per 96 ms is by no means fast all... Even 1 per 20 should have a negligible effect on the performance. I know because I was once creating an auto-waypoint generator because I didn't fancy placing them myself over large areas. First stage was to distribute the map into "cells" (each 1x1x1 in size). Then was to analyse each cell, by firing a number of rays straight down inside the 1x1 cell. The number of rays was user definable, anywhere between 2x2 to 100x100, 10x10 being the default as it was good enough for high precision. To do an area of 200x50x200 cells at 10x10 scan resolution took no more than about a minute. This was a DBP project though, and it used Newton 1.53 I can't see Newton 2 in Leadwerks giving wildly different sort of times. But I've yet to port it over to Loadwerks because I've not yet needed it. Quote LE Version: 2.50 (Eventually) Link to comment Share on other sites More sharing options...
Flexman Posted April 22, 2011 Share Posted April 22, 2011 I don't want to hijack the thread but shell casing ejection is not overkill. It's a feature observed by crews and night vision footage of engagements, clearly visible from other helicopters and certainly visible in external views particually the gun camera view in which they fly past. They are recycled much faster than bullets since they don't persist in the viewport very long, typically only 15 bodies are required (at altitude they have fallen away, on the ground they form a small pile that remains a consistent size). A hand-held gun would benefit just the same, having shells bounce around your feet with audio FX would be a nice touch. So easy to add a body that is thrown out of the chamber position. Throw in a user setting for debris or small detail objects to set the number you want live for each player. Quote 6600 2.4G / GTX 460 280.26 / 4GB Windows 7 Author: GROME Terrain Modeling for Unity, UDK, Ogre3D from PackT Tricubic Studios Ltd. ~ Combat Helo Link to comment Share on other sites More sharing options...
VeTaL Posted June 30, 2011 Share Posted June 30, 2011 Just wanted to add own 5 cents. In old Gamestudio magazine, it was said that there are three types of weapon: - raytrace (crossbow in Half-life with zoom) - physic bullet (crossbow in Half-life without zoom, mashine gun and so on) - grenades (you know, what i mean ) - actually, this is physic bullet with huge mass and low speed So its for you to chose, which solution suits you best Quote Working on LeaFAQ Link to comment Share on other sites More sharing options...
Rick Posted June 30, 2011 Author Share Posted June 30, 2011 At the time I went with physics bullets. It worked pretty well. Thanks! Quote Link to comment Share on other sites More sharing options...
TylerH Posted July 10, 2011 Share Posted July 10, 2011 I was always curious as how to, fundamentally, this functionality is implemented in games. Regardless of whether you use raycasts or a physics shape + collision, there still is some backend system that has to register "hits", hit info, etc. and dish it back out to be processed, damaged applied, enemies killed, and such. Is there a cookie-cutter way to do such a thing? Or does every one, from indie to big name AAA studios, just reinvent the wheel everytime they need a gun to fire at other entities/actors/whateveryoucallthem? I haven't done as much research into the topic as I should have, but when I was writing Weaponwerks and my other little libraries to have complex weapons systems in first person, I kind of got stuck around the whole "oh hey I can shoot pretty bullets with effects and ricochets, but how do I make them actually do something in a neat, organized, OO, expandable way?". Any suggestions, tips, advice? Quote nVidia 530M Intel Core i7 - 2.3Ghz 8GB DDR3 RAM Windows 7 Ultimate (64x)----- Visual Studio 2010 Ultimate Google Chrome Creative Suite 5 FL Studio 10 Office 15 ----- Expert Professional Expert BMX Programmer ----- Link to comment Share on other sites More sharing options...
VeTaL Posted July 10, 2011 Share Posted July 10, 2011 //Is there a cookie-cutter way to do such a thing? Or does every one, from indie to big name AAA studios, just reinvent the wheel everytime they need a gun to fire at other entities/actors/whateveryoucallthem? well, Newton allows you to get hited entity eithry by ray or the physical bullet. Quote Working on LeaFAQ Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.