Jazz Posted November 22, 2016 Share Posted November 22, 2016 Ever since decals were added to the engine all guns shoot down and to the right. In the pic I was shooting where the reticle is. This is a new FPS project with the stock fps player prefab and autopistol prefab in non-beta. Quote --- Scott Using Windows 7 Ultimate 64 bit/Core I7-2700K @ 4312mhz/24G RAM/Nvidia GTX 1060 Link to comment Share on other sites More sharing options...
Josh Posted November 22, 2016 Share Posted November 22, 2016 It's leaving the barrel and moving forward. Therefore it will converge with the center on the horizon. The same will happen in real life, unless you shoot bullets from your eyes. Do you shoot bullets from your eyes? 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Jazz Posted November 22, 2016 Author Share Posted November 22, 2016 I can try! Ok understood. You may delete this thread. Quote --- Scott Using Windows 7 Ultimate 64 bit/Core I7-2700K @ 4312mhz/24G RAM/Nvidia GTX 1060 Link to comment Share on other sites More sharing options...
Rick Posted November 22, 2016 Share Posted November 22, 2016 Wouldn't most games not do this? Don't most games raycast out from the center of the camera so the spread would be around the crosshairs (where most people expect the bullet to be around). Quote Link to comment Share on other sites More sharing options...
Josh Posted November 22, 2016 Share Posted November 22, 2016 I have noticed the opposite. Also the visual tracer would look funny if it was coming from your eye. You can do a raycast every once in a while and check the distance of the hit object, then aim the bullet travectory at that point. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Rick Posted November 22, 2016 Share Posted November 22, 2016 I would think the picking is done via the "eyes" to get the point where it would hit (which is lined up to the crosshairs) in the 3D world, and then the line pick would be from the barrel to that point for the tracer. Quote Link to comment Share on other sites More sharing options...
Josh Posted November 22, 2016 Share Posted November 22, 2016 They all line up at the horizon. If there is an object in front of the player then the gun has to be redirected to the point on the object where the eyes are looking. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Jazz Posted November 22, 2016 Author Share Posted November 22, 2016 Just checked some games. Half-Life, Team Fortress 2, Far Cry 3, 7 Days to Die, Borderlands 2 all shoot dead on the reticle even up close... I'd check more but I just end up playing them. 2 Quote --- Scott Using Windows 7 Ultimate 64 bit/Core I7-2700K @ 4312mhz/24G RAM/Nvidia GTX 1060 Link to comment Share on other sites More sharing options...
macklebee Posted November 22, 2016 Share Posted November 22, 2016 The shot is going where the gun is pointed. You can pick from the camera view if you don't like that or you could just rotate and position the gun to shoot at the spot you want. If you use the gun's position/rotation then it would also incorporate the small sway and bob that causes the minor offsets in the bullet impact. The current fpsgun script is picking along the gun's axis. So if you want that, then try changing in the prefab setup to something that works: Script.offset to 0,-0.17,0 Script.rotation to -29,-6,0 But then you might not like the look of the gun in the scene, so at that point perform the pick from the camera. Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Josh Posted November 22, 2016 Share Posted November 22, 2016 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
macklebee Posted November 22, 2016 Share Posted November 22, 2016 or maybe this so it removes the problem altogether: 1 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Josh Posted November 22, 2016 Share Posted November 22, 2016 In the first image, the gun would be constantly rotating as you look around the level. Which is actually what would happen if people shot from the hip expecting it to go where their eye is, but would look funny. The second image shows the player aiming with ironsights. My image above shows what I would do if I wanted to change this. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
macklebee Posted November 22, 2016 Share Posted November 22, 2016 In my first image its just rotated towards the center of the screen but not constantly rotating - granted this will only give the results you want within a certain range. In the second image, the player is not aiming with ironsights but he is holding the gun at the center of his body - much like you would do if holding the pistol with both hands (which the fpsgun prefab is doing). Its all a matter of preference. Your second image would basically require two picks - one from the camera to hit point, then from gun to that hit point. Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Rick Posted November 22, 2016 Share Posted November 22, 2016 I think mac's first image is what it's like in most games. The gun is always rotated a little so you can see the kick *** model of the gun. Then the picking is done from center and as stated if you want tracers (not all games have these) you do the 2nd pick from barrel to picked spot the center of screen pick hit. http://www.gamespresso.com/wp-content/uploads/2016/04/ProjectNovaScreenshot2.0.jpg Quote Link to comment Share on other sites More sharing options...
gamecreator Posted November 22, 2016 Share Posted November 22, 2016 100% agree that games have trained us that we hit the crosshairs no matter what (given no accuracy variance). The gun's position is irrelevant. This isn't real life; it's gameplay. The exception to this is if you really want to create a hardcore army simulation or something but most games, as SGB said above, don't do that. Quote Link to comment Share on other sites More sharing options...
Josh Posted November 22, 2016 Share Posted November 22, 2016 I think mac's first image is what it's like in most games. The gun is always rotated a little so you can see the kick *** model of the gun. Then the picking is done from center and as stated if you want tracers (not all games have these) you do the 2nd pick from barrel to picked spot the center of screen pick hit. http://www.gamespresso.com/wp-content/uploads/2016/04/ProjectNovaScreenshot2.0.jpg What would you suggest doing if the tracer hits something and prevents the gun from firing at the target? Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Rick Posted November 22, 2016 Share Posted November 22, 2016 1) Pick from center of camera. Now you have the point in 3D space that should be shot at. 2) Line pick from barrel of gun to the 3D point that you got from step 1 3) You now have a line the tracer can travel along from the barrel of the gun to the picked spot in step 1 I don't see how the drawing you have could happen. Assuming the end of your dotted line is a wall that got picked from step 1, then your line from gun isn't going to that point in 3D one for some reason. How did you come up with that tracer line? You aren't shooting that tracer out based on the guns rotation, you're shooting a line from the barrel to the picked 3D point in step 1. It can be hard to tell but from my perspective you can sort of see how that works. It's not shooting out based on the rotation of the gun. Yes, it's not real life but it's what most games do because it looks better to be able to see the side of the gun because the gun is such a big deal in fps games. You can see in the 2nd video, and as I'm sure you noticed in my explanation, if anything is in the tracer line but not in crosshairs the tracer will go through it but the thing won't get hit. Tracers go so fast games just don't care about that. 1 Quote Link to comment Share on other sites More sharing options...
Josh Posted November 22, 2016 Share Posted November 22, 2016 Bullets don't get instantly raycast. They travel through space, which is why you can see the tracer, It is completely possible for the tracer path to not be able to reach the point you are looking at, if an object is blocking it. If you do as my picture shows above it will work perfectly. The actual angle of the gun is irrelevant. It's just positioned and rotated to look good. You don't want to gun constantly turning back and forth depending on what is in front of the player. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Rick Posted November 22, 2016 Share Posted November 22, 2016 Are you trying to redefine FPS games? People expect, as the OP did, bullets go to the crosshairs. Nobody is adjusting and aiming more up and left in FPS games. The OP wanted to hit the point where the 2 white lines crossed but that's not what happened. A player got something that he expected from playing all other FPS games and something else happened. That's not ideal. Quote Link to comment Share on other sites More sharing options...
macklebee Posted November 22, 2016 Share Posted November 22, 2016 Just rotate the gun to point towards the center. Do the pick from the camera to the center where the crosshair is at, The bullet still comes from the gun and will hit at the crosshair. As long as the gun is rotated to in the direction of where the crosshair is at, no one will notice. FSPGun.lua: --if self.entity.world:Pick(bullet.position,bullet.position+travel,pickinfo,0,true,Collision.Projectile) then -- below replaces this in Script:Update() if self.player.camera:Pick(context:GetWidth()/2,context:GetHeight()/2,pickinfo,0,true,Collision.Projectile) then Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Josh Posted November 22, 2016 Share Posted November 22, 2016 Just rotate the gun to point towards the center. Do the pick from the camera to the center where the crosshair is at, The bullet still comes from the gun and will hit at the crosshair. As long as the gun is rotated to in the direction of where the crosshair is at, no one will notice. FSPGun.lua: --if self.entity.world:Pick(bullet.position,bullet.position+travel,pickinfo,0,true,Collision.Projectile) then -- below replaces this in Script:Update() if self.player.camera:Pick(context:GetWidth()/2,context:GetHeight()/2,pickinfo,0,true,Collision.Projectile) then That's what I'm saying, except instead of rotating the gun, just alter the bullet trajectory. There is no need to turn the gun back and forth. I checked In Doom 2016 and I am sure that is exactly what they are doing. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
macklebee Posted November 22, 2016 Share Posted November 22, 2016 That's what we all have been saying as well - the gun just needs to look like its pointed in the right direction. You can do a pivot/point but honestly i didnt see much difference. So as long as the gun is positioned/rotated to look like it could make that shot, then the player will be no wiser that the pick is coming from the camera and not the end of the gun. Not that the end user cares - they just want the bullet to hit where they aim. 1 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
fred.Man Posted October 24, 2019 Share Posted October 24, 2019 I know this thread is very old. But since I've only been using Leadwerks for about 95 hours, I concentrated on other things first. But now the time has come when I would like to solve this problem. As a confirmed FPS player, I'd like to point out that the crosshair and bullet impact behavior bothered me right from the start. At the moment I'm still using the @macklebee suggested solution which reminds me a lot of the FPS games of the 90s. I have checked Josh's cross-reference to the game DOOM from 2016, but I would like to point out that this is not the case. The bullet impacts are either inside (picture 01 - Doom Pistol) or in and around (picture 02 Doom Shotgun) the area indicated by the crosshairs. To my question. Has anyone so far found a solution that represents the Bullet Impacts as in Doom 2016 in or in and around the crosshairs? I am already convinced that naturalized GamePlay elements should also be found in a game engine. Thanks for reading and no hard feelings. 1 Quote Link to comment Share on other sites More sharing options...
reepblue Posted October 24, 2019 Share Posted October 24, 2019 Just make the entity point towards the look position from the camera. This should give you an idea. Might not compile, just presto code. //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void MyCoolWeapon::Fire() { auto pick = PickInfo() auto p0 = m_pPlayer->GetCamera()->GetPosition() auto p1 = Transform::Point(0,0,999,m_pPlayer->GetCamera(),NULL) auto lookpos = Vec3(0) if entity->GetWorld()->Pick(pick,p0,p1,0,true,Collision:LineOfSight) { lookpos = pick.position; } // Create A Projectile auto i = m_pProjectile->Instance(); i->SetMatrix(m_pPlayer->GetCamera()->GetMatrix()); i->Move(0, 0, 0.25); i->Show(); i->SetKeyValue("starttime", to_string(Time::GetCurrent())); i->Point(lookpos->GetPosition(),2,1,0); m_hBullets.push_back(i); // <-- Your bullet vector to cycle through all the bullets you've fired. } //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void MyCoolWeapon::UpdateWorld() { if (m_hBullets.size() > 0) { for (auto& b : m_hBullets) { if (b != NULL) { auto pickinfo = PickInfo(); auto pos = b->GetPosition(true); auto forward = Transform::Point(0, 0, PROJECTILE_SPEED / 60.0 * Time::GetSpeed(), b, NULL); auto result = b->world->Pick(pos, forward, pickinfo, 0, true, Collision::LineOfSight); if (b->Hidden() == false) { if (result) { b->Release(); b = NULL; } } else { m_hBullets.erase(std::remove(m_hBullets.begin(), m_hBullets.end(), b), m_hBullets.end()); } } } } Quote Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon! Link to comment Share on other sites More sharing options...
fred.Man Posted October 25, 2019 Share Posted October 25, 2019 Hello reepblue and thanks for your feedback. Your script contains for me very interesting solutions which I will consider for my project in the future to create appropriate behaviors for the player. ;) 1 Quote 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.