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 /
avatar image
0
Question by Phantom07 · Sep 12, 2019 at 09:51 AM · movementinputplayer movementrigidbody.velocitybuilds

Rigidbody movement not working after build

After I build the game, none of the buttons to move or jump work.

  • The movement works fine in the editor.

  • the rigidbody still is affected by gravity after the build.

  • the inputs for pausing still work after the build.


I've tried restating my computer and moving the files to a new project, but it didn't work.


Here is my movement script \/\/\/

 using System;
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityStandardAssets.CrossPlatformInput;
 using UnityStandardAssets.Utility;
 using UnityStandardAssets.Utility.Inspector;
 
 public class playerMovement : MonoBehaviour
 {
     public float WalkSpeed = 400;
     public float RunSpeed = 500;
     public bool IsGrounded;
     public bool CanMove = true;
     public GameObject Player;
     public GameObject ResumeButton;
     public Rigidbody PlayerRb;
     public float HorizontalAxis;
     public float VerticalAxis;
     public float JumpForce = 150;
     public float MovementSpeed = 400;
     public KeyCode Pause;
     public KeyCode Run;
     public Vector3 MoveDirection;
     public Vector3 YVelFix;
     void Awake()
     {
         Run = KeyCode.LeftShift;
         Pause = KeyCode.Escape;
         Player = GameObject.FindWithTag("Player");
         PlayerRb = Player.GetComponent<Rigidbody>();
     }
 
     private void Start()
     {
         CanMove = true;
         ResumeButton.SetActive(false); //immediatly turns off the pause menu
     }
 
     private void OnTriggerEnter(Collider other)//ground check
     {
         IsGrounded = true;
     }
     private void OnTriggerExit(Collider other)//ground check
     {
         IsGrounded = false;
     }
 
     void Update()
     {
         if (Input.GetKey(KeyCode.A))//left movement
         {
             HorizontalAxis = -1;
         }
         else if (Input.GetKey(KeyCode.D))//right movement
         {
             HorizontalAxis = 1;
         }
 
         if (Input.GetKey(KeyCode.S))//back movement
         {
             VerticalAxis = -1;
         }
         else if (Input.GetKey(KeyCode.W))//forward movement
         {
             VerticalAxis = 1;
         }
         if (Input.GetKeyUp(KeyCode.A))//stops movement
         {
             HorizontalAxis = -0;
         }
         if (Input.GetKeyUp(KeyCode.D))//stops movement
         {
             HorizontalAxis = 0;
         }
 
         if (Input.GetKeyUp(KeyCode.S))//stops movement
         {
             VerticalAxis = 0;
         }
         if (Input.GetKeyUp(KeyCode.W))//stops movement
         {
             VerticalAxis = 0;
         }
         MoveDirection = (HorizontalAxis * transform.right + VerticalAxis * transform.forward).normalized;//finds direction of movement
     }
     
     void FixedUpdate()
     {
         // Running
         if (Input.GetKey(Run))//run button
         {
             MovementSpeed = RunSpeed;
         }
         else
         {
             MovementSpeed = WalkSpeed;
         }
 
         // Pausing
         if (Input.GetKeyDown(Pause))//pause button
         {
             if (CanMove == true)
             {
                 Button.SetActive(true);
                 CanMove = false;
                 Time.timeScale = 0.2f;
             }
         }
 
         if (CanMove == true)//jumping
         {
             if (CanMove == true && IsGrounded == true)
             {
                 if (Input.GetKey(KeyCode.Space))
                 {
                     PlayerRb.AddForce(Vector3.up * JumpForce);
                 }
             }
             Move();
         }
     }
 
     public void Resume()//resume button for pause menu
     {
         CanMove = true;
         Time.timeScale = 1.0f;
         Button.SetActive(false);
     }
 
     void Move()//movement
     {
         YVelFix = new Vector3(0, PlayerRb.velocity.y, 0);
         PlayerRb.velocity = MoveDirection * MovementSpeed * Time.deltaTime;
         PlayerRb.velocity += YVelFix;
     }
 }




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

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

182 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Input System Can't Catch Event on Update 0 Answers

OnMove Vector2 never returns to (0,0) 1 Answer

Why am I losing some inputs on Update function? 0 Answers

Character triple+ Jumping: Please Help! 0 Answers

How to make a object go and come back with a mouse click 1 Answer


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