Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by AlphaTest · Apr 20, 2016 at 04:48 AM · error message

It says I have to go to the input manager and input the following code and I don't know how to do that./ Help Please? Anybody/

using UnityEngine; using System.Collections;

[RequireComponent(typeof(CharacterController))] public class PlayerMovement : MonoBehaviour { public bool canControl = true;

 public float runSpeed = 5.0f;
 public float sprintSpeed = 8.0f;
     
 public AnimationCurve slopeSpeedMultiplier = new AnimationCurve(new Keyframe(-90, 1.5f), new Keyframe(0, 1), new Keyframe(90, 0));
     
 public float crouchSpeedModifier = 0.55f;
 public float normalHeight = 1.75f;
 public float crouchHeight = 1.0f;
 
 public float gravity = 9.81f;
 public float maxFallSpeed = 100.0f;
     
 public float jumpHeight = 2.0f;
 
 public LayerMask crouchDetect;
 public float pushPower = 1.6f;
 
 [HideInInspector] public CollisionFlags collisionFlags; 
 [HideInInspector] public bool grounded;
 [HideInInspector] public bool sprinting;
 [HideInInspector] public bool crouching;
 [HideInInspector] public bool inAir;
 [HideInInspector] public bool floating;
 [HideInInspector] public float impactVelocity;
 [HideInInspector] public CharacterController controller;

 private bool dontStand = false;
 private RaycastHit ds;
 private float moveSpeedAim;
 private float curSpeed;
 private Vector3 moveDirection;
 
 void Start() {
     controller = GetComponent<CharacterController>();
     moveSpeedAim = 1;
 }
 
 void LateUpdate() {
     if(!grounded) {
         impactVelocity = -controller.velocity.y;
         floating = true;
     }
 }
 
 void Update() {
     grounded = controller.isGrounded;
     if(grounded) {
         moveDirection = new Vector3(Input.GetAxis("Horizontal") * moveSpeedAim, -1, Input.GetAxis("Vertical") * moveSpeedAim);
         
         if(moveDirection != Vector3.zero) {
             float directionLength = moveDirection.magnitude;
             moveDirection /= directionLength;
             directionLength = Mathf.Min(1, directionLength);
             directionLength  = Mathf.Pow(directionLength, 2);
             moveDirection *= directionLength;
         }
         
         moveDirection = transform.TransformDirection(moveDirection);
         
         if(Input.GetButton("Run") && Input.GetAxis("Horizontal") == 0 && Input.GetAxis("Vertical") > 0 && !crouching && controller.velocity.magnitude > 0.5f) {
             moveDirection *= sprintSpeed;
             sprinting = true;
         }
         else if(crouching && !sprinting) {
             moveDirection *= runSpeed * crouchSpeedModifier;
         }
         else {
             moveDirection *= runSpeed;
             sprinting = false;
         }
         
         if(Input.GetButton("Jump")) {
             moveDirection.y = jumpHeight;
         }

         if(Physics.Raycast(transform.position, transform.up, out ds, (controller.height * 0.5f) + 0.1f, crouchDetect.value)) {
             dontStand = true;
         }
         else {
             dontStand = false;
         }
     
         if(!sprinting) {
             if(Input.GetButton("Crouch")) {
                 controller.height = Mathf.Lerp(controller.height, crouchHeight, Time.deltaTime * 6);
                 controller.center = new Vector3(0, Mathf.Lerp(controller.center.y, -((normalHeight - crouchHeight) / 2), Time.deltaTime * 6), 0);
                 GameObject.Find("Head").SendMessage("CrouchMoveY", -(normalHeight - crouchHeight));
                 crouching = true;
             }
             
             if(!Input.GetButton("Crouch") && !dontStand){
                 controller.height = Mathf.Lerp(controller.height, normalHeight, Time.deltaTime * 6);
                 controller.center = new Vector3(0, Mathf.Lerp(controller.center.y, 0, Time.deltaTime * 6), 0);
                 GameObject.Find("Head").SendMessage("CrouchMoveY", 0.0f);
                 crouching = false;
             }
         }
     }
     else {
         inAir = true;
     }
     
     if(moveDirection.y > -maxFallSpeed) {
         moveDirection.y -= Time.deltaTime * gravity;
     }
     
     controller.Move(moveDirection * Time.deltaTime);
 }
 
 void OnControllerColliderHit (ControllerColliderHit hit) {
 }
 
 public void SlowWhenAim(float spd) {
     moveSpeedAim = spd;
 }

}

Comment
Add comment · Show 2
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 nug700 · Apr 20, 2016 at 07:08 AM 0
Share

What, exactly, says you need to do this?

avatar image meat5000 ♦ nug700 · Apr 20, 2016 at 07:29 AM 0
Share

The Lord of the Space Cats

0 Replies

· Add your reply
  • Sort: 

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Error CS0535? 0 Answers

Roll a Ball script error?! 2 Answers

NullReferenceException: Object reference not set to an instance of an object 1 Answer

Scene Won't Load 1 Answer

Socket: bind failed, error 3 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