Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by bula · Dec 16, 2011 at 07:56 PM · inputcharactername

Input Shift name

Well i just added a sprint script to my character. Now I want to name the shift button onto the input thingy. Amean to go edit-project settings-input. My problem is this. 1)I read through many tutorials that i need my original name(How to I name this script) 2)How do i name the left shift to actually activate the sprint script? Ty in advance.Any help will be apreciated. Ty

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by 4illeen · Dec 16, 2011 at 08:14 PM

Inside the script you should have something like this

 if (Input.GetButton("Sprint"))
 DO THE SPRINT

"Sprint" is the name of your sprint key you need to setup in Edit->Project Settings->Input

to do so create a new button there or use any existing one you don't need. In the Name field you put the same name you have in your script - in my situation it's Sprint. In the Positive Button field write e.g left shift. If you want and alternative button, fill the field called Alt Positive Button with e.g right shift

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image 4illeen · Dec 16, 2011 at 08:17 PM 0
Share

1)I read through many tutorials that i need my original name(How to I name this script)

if it's a C# script, you need to name it just like the class inside it e.g public class SprintScript : $$anonymous$$onoBehaviour - then your script should be called SprintScript.cs I'm not sure for other languages

avatar image bula · Dec 17, 2011 at 09:52 AM 0
Share

I think you get it right 4illeen let me check mate...

avatar image
0

Answer by bula · Dec 17, 2011 at 10:15 AM

This is my script(full)

  var maxForwardSpeed     : float = 20.0;

  var maxSidewaysSpeed    : float = 20.0;

  var maxBackwardsSpeed   : float = 10.0;

  var maxSprintSpeed   : float = 30.0;



 if (Input.GetButtonDown("Sprint")) 

 {

 maxForwardSpeed = maxSprintSpeed ;

 maxSidewaysSpeed = maxSprintSpeed ;

 maxBackwardSpeed = 0 ;

      }



 if (Input.GetButtonUp("Sprint")) 

 {

 maxForwardSpeed = maxForwardSpeed;

 maxSidewaysSpeed = maxSidewaysSpeed;

 maxBackwardsSpeed = 0;
  
 maxSprintSpeed = 0;

 }


I gone the sprint button in edit-project settings - input and i did this: 1)I named the it Sprint 2)I named the positive button "left shift" What is the problem cause it's not working at all

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image 4illeen · Dec 17, 2011 at 10:57 AM 0
Share

What you pasted just changes variables, what movement script do you use? Also when Sprint button is up the line`maxForwardSpeed = maxForwardSpeed;` does nothing, because it's already changed to maxSprintSpeed. You need something like your currentSpeed and change it to either maxForwardSpeed or maxSprintSpeed.

But first of all we need to see your movement script - did you use Unity's First (or 3rd) Person Controller prefab?

avatar image bula · Dec 17, 2011 at 11:29 AM 0
Share

i am using fps movement script...(first person shooter) and what you want to say is this?

 maxForwardSpeed = 20 ;
 
 maxSidewaysSpeed = 20;

Best regards i'm waiting your answear

avatar image 4illeen · Dec 17, 2011 at 12:00 PM 0
Share

To change the speed of your character when the SPRINT button is being pressed you need to find out which variable the fps script uses for player's speed - let's say it's called speed. Then the script would look like this:

Start(){

speed = maxForwardSpeed; //Player will start with speed = 20.0 }

Update(){

if (Input.GetButtonDown("Sprint")) //When you push the button

speed = maxSprintSpeed; //change the speed to sprint speed, so speed = 30

if (Input.GetButtonUp("Sprint")) //When you stop pushing the button

speed = maxForwardSpeed; //change the speed to normal, so speed = 20

}

once again - speed is the variable your fps script uses as character's movement speed, maxSprintSpeed & maxForwardSpeed are the variables you set

avatar image bula · Dec 17, 2011 at 05:09 PM 0
Share

The script uses the maxForwardSpeed thing.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Input for Character Movement 2 Answers

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

How do i make the game start so that the character is already running? 1 Answer

Move camera with mouse (2D) 1 Answer

Enemy not moving towards Player 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges