ChudStuddley Posted January 9, 2014 Share Posted January 9, 2014 Hi I am not very experienced at all with Lua/Programming, would it be possible for anyone to help me with steps or a small tutorial even on adding in crouching functionality and iron-sighting to the default FPS/FPSWeapon scripts? I tried my own at the Crouching one by editing somethings and even tried converting over the old FPS controller from Leadwerks 2 but it had some errors and I reversed the changes. Thanks in advance for any help provided! P.S I understand the iron-sighting may or may not come down to animations in the gun itself, if that is the case then if you could explain loading a gun/animations in Lua or point me to somewhere that would help me out more I could just use some FPS Creator weapons. Sorry about the wall-of-text by the way! Quote Link to comment Share on other sites More sharing options...
Rick Posted January 9, 2014 Share Posted January 9, 2014 When I was in the FPS script that comes with 3.1 I noticed some crouch code commented out. Not sure why they didn't add it, but did you see that also and is that what you were looking at? I could give this a go, but I won't be home for 10 more hours. By iron-sighting I assume you mean some effect like: http://upload.wikimedia.org/wikipedia/commons/4/4d/Visierlinie.jpg You would have to position the model just right and then use blur post processing script (I think) to blur things close to the camera. Post processing scripts aren't here yet but they will be a part of 3.1 as far as I understand. 1 Quote Link to comment Share on other sites More sharing options...
ChudStuddley Posted January 9, 2014 Author Share Posted January 9, 2014 When I was in the FPS script that comes with 3.1 I noticed some crouch code commented out. Not sure why they didn't add it, but did you see that also and is that what you were looking at? I could give this a go, but I won't be home for 10 more hours. By iron-sighting I assume you mean some effect like: http://upload.wikimedia.org/wikipedia/commons/4/4d/Visierlinie.jpg You would have to position the model just right and then use blur post processing script (I think) to blur things close to the camera. Post processing scripts aren't here yet but they will be a part of 3.1 as far as I understand. Yeah I did see the crouching part was just comments so I tried to see if it worked by un-commenting it (sounds weird lol) to no avail, and yes that is a effect that I want to achieve but without the blur, I just prefer being able to aim down my gun, while not entirely realistic in sight due to usually having the gun incredibly close to the camera, it's a nice effect and common in FPS games nowadays. Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted January 9, 2014 Share Posted January 9, 2014 I added the crouching behaviour in the tutorial file during development but josh didnt want to use it for the tutorials. Quote Link to comment Share on other sites More sharing options...
ChudStuddley Posted January 10, 2014 Author Share Posted January 10, 2014 I added the crouching behaviour in the tutorial file during development but josh didnt want to use it for the tutorials. Is that why it's in a commented section as opposed to code? If so, how come taking away the -- doesn't enable it, is it unfinished/waiting for a update to leadwerks or something? Quote Link to comment Share on other sites More sharing options...
ZioRed Posted January 11, 2014 Share Posted January 11, 2014 Josh said that crouching was still not supported but would be implemented in SetInput sooner, here is, but it was about 1 month ago so I don't know if it has already been implemented/supported in this early version of 3.1 Quote ?? FRANCESCO CROCETTI ?? http://skaredcreations.com Link to comment Share on other sites More sharing options...
Joshua Posted January 12, 2014 Share Posted January 12, 2014 For iron sights, you can use a couple Vec3 or Mat4 to represent a m_weaponOffset and m_weaponOffsetRotation while idle and while aiming. you could then use Math::Curve(..) to interpolate between the offsets to allow a smooth transition between the two positions/rotations. For crouching, you can have a bool m_isCrouching value to indicate if the player is crouching, say if Key::ControlKey is pressed. If the player is crouching you set something like m_playerHeight to something like m_crouchHeight and position your camera accordingly. My code is in C++ but I am sure it can easily be translated to Lua. crouching ex. // Check for crouching. m_isCrouching = window->KeyDown(Key::ControlKey); // Set height appropriately SetHeight(( m_isCrouching ? m_crouchHeight : m_standHeight)); // Get a pointer to the game's camera Camera* gameCamera = GetCamera(); // Get the existing camera's position Vec3 newCamPos = gameCamera->GetPosition(); // set the new camera position and smooth the y-Position newCamPos = Vec3(GetPosition().x, Math::Curve(GetPosition().y + GetHeight(), gameCamera->GetPosition().y, m_viewSmoothing), GetPosition().z); // apply the final results to the viewing camera gameCamera->SetPosition(newCamPos); 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.