|
Post by jamesun on Jun 18, 2018 17:33:55 GMT
Hey everyone,
First of all let me state that I am extremely novice when it comes to code, and have been dabbling in a way to create a getbuttondown command on the Third Person Shooter in order to have an extra toggle for walking, instead of just running and sprinting. How would I go about this? Also, I'm completely new to the forum, so if I am posting this in the incorrect category, my apologies. Cheers in advance for your input.
James
|
|
|
Post by Invector on Jun 18, 2018 17:44:06 GMT
That's pretty easy actually, you just need to create a method like this:
if (Input.GetKey(KeyCode.LeftControl)) SetWalkByDefault(true); else SetWalkByDefault(false);
And call it in the InputHandle()
In this example I quickly did with Unity input system, but if you want you can do it with our Input system to display the variable in the ThirdPersonInput inspector just like our other inputs, just follow the other variables example, it's pretty simple.
|
|
|
Post by jamesun on Jun 18, 2018 20:21:41 GMT
That's pretty easy actually, you just need to create a method like this: if (Input.GetKey(KeyCode.LeftControl)) SetWalkByDefault(true); else SetWalkByDefault(false); And call it in the InputHandle() In this example I quickly did with Unity input system, but if you want you can do it with our Input system to display the variable in the ThirdPersonInput inspector just like our other inputs, just follow the other variables example, it's pretty simple. Thanks for your reply! I think i understood everything you said, but just to make sure: Add these lines directly to the shooter/melee input script or is it best practice to create a separate script, and call the input there? As for everything else, I can then just manage this "action" using your input to set the desired buttondown directly in the inspector, correct? Thank you for your patience and I do apologize if this os extremely basic stuff. But I've only been teaching myself C# for 2 months and everything is still a bit overwhelming, hehe. Will have a go at this as soon as I get off work. Many thanks!
|
|