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 orangeflame · Dec 28, 2015 at 07:41 PM · build-errortime.deltatimeanimation scripttransformdirection

animation script behaving differently after build and run on a different computer.

ANSWER: I'm an idiot that forgot to include Time.deltaTime in my position update statement. -_- sorry for bothering all of you.

how I should have wrote the statement:

 derp.transform.position += derp.transform.TransformDirection(Vector3.up) * (1f/50)*derp.GetComponent<playerScriptWithAnimation>().jumpForce * Time.deltaTime;


I have a script attached to my jump animation that is suppose to move my character upward while in that animation state. It works if I run it in unity or on the same computer I am using to make it but all other devices(laptops, computers) seem to have an issue. I have tried searching for an answer online but either I am using the wrong words or I can't find it. Also, I didn't find any errors in the output_log.txt and my other animation scripts work excpet the one I have for moving has the character moving oddly slower. Just a few guessing of mine(Time.deltaTime works differently after build, TransformDirection may work differently after build)


here is a link to download the desktop version of the game: http://www.mediafire.com/download/covx5745l0w67ib/Fire_Emblem_Fan-Made_Fighting_Game_v0.0.2_Data.zip


Below is the one line of code in question:

 derp.transform.position += derp.transform.TransformDirection(Vector3.up) * (1f/2000)*derp.GetComponent<playerScriptWithAnimation>().jumpForce;


Here are other questions I feel are related to mine to show I'm not the only one experiencing this: http://answers.unity3d.com/questions/801610/camera-does-not-follow-player-after-build.html http://answers.unity3d.com/questions/745397/mouse-look-not-working-after-build.html http://answers.unity3d.com/questions/894555/transform-bug-only-happening-in-compiled-build.html


Below is the whole Script:

 using UnityEngine;
 using System.Collections;
 using System.IO;
 
 public class animationJump : StateMachineBehaviour {
     
     public GameObject derp;
 
     // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
     override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
         if (animator.GetInteger ("playerNumber") == 1 && 
             GameObject.FindGameObjectWithTag ("player1")) {
             derp = GameObject.FindGameObjectWithTag ("player1");
         } else if (animator.GetInteger ("playerNumber") == 2 && 
                    GameObject.FindGameObjectWithTag ("player2")) {
             derp = GameObject.FindGameObjectWithTag ("player2");
         } else if (animator.GetInteger ("playerNumber") == 3 && 
                    GameObject.FindGameObjectWithTag ("player1assist")) {
             derp = GameObject.FindGameObjectWithTag ("player1assist");
         } else if (animator.GetInteger ("playerNumber") == 4 && 
                    GameObject.FindGameObjectWithTag ("player2assist")) {
             derp = GameObject.FindGameObjectWithTag ("player2assist");
         } else {
             Debug.LogError("wut");
         }
         derp.GetComponent<playerScriptWithAnimation> ().characterState = "jump";
         derp.GetComponent<Rigidbody> ().useGravity = false;
     }
     
     // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
     override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
         if (derp == null) {
             if (animator.GetInteger ("playerNumber") == 1 && 
                 GameObject.FindGameObjectWithTag ("player1")) {
                 derp = GameObject.FindGameObjectWithTag ("player1");
             } else if (animator.GetInteger ("playerNumber") == 2 && 
                 GameObject.FindGameObjectWithTag ("player2")) {
                 derp = GameObject.FindGameObjectWithTag ("player2");
             } else if (animator.GetInteger ("playerNumber") == 3 && 
                 GameObject.FindGameObjectWithTag ("player1assist")) {
                 derp = GameObject.FindGameObjectWithTag ("player1assist");
             } else if (animator.GetInteger ("playerNumber") == 4 && 
                 GameObject.FindGameObjectWithTag ("player2assist")) {
                 derp = GameObject.FindGameObjectWithTag ("player2assist");
             } else {
                 Debug.LogError ("wut");
             }
         } 
         derp.transform.position += derp.transform.TransformDirection(Vector3.up) * (1f/2000)*derp.GetComponent<playerScriptWithAnimation>().jumpForce;
         if (animator.GetInteger("XSpeed") == 1) {
             /*derp.GetComponent<Rigidbody> ().AddForce (derp.transform.forward * (-1.5f) * derp.GetComponent<playerScriptWithAnimation> ().movementForce);
                 if (Mathf.Abs (derp.GetComponent<Rigidbody> ().velocity.x) > derp.GetComponent<playerScriptWithAnimation> ().maxMovementSpeed) {
                     derp.GetComponent<Rigidbody> ().velocity = new Vector3 (derp.GetComponent<playerScriptWithAnimation> ().maxMovementSpeed * (derp.GetComponent<Rigidbody> ().velocity.x / Mathf.Abs (derp.GetComponent<Rigidbody> ().velocity.x)),
                                                                           derp.GetComponent<Rigidbody> ().velocity.y,
                                                                           derp.GetComponent<Rigidbody> ().velocity.z);
                 }*/
             derp.transform.position += derp.transform.TransformDirection(Vector3.forward) * (-1f/100) * derp.GetComponent<playerScriptWithAnimation>().movementForce;
         } else if (animator.GetInteger("XSpeed") == -1) {
             /*derp.GetComponent<Rigidbody> ().AddForce (derp.transform.forward * 2f * derp.GetComponent<playerScriptWithAnimation> ().movementForce);
                 if (Mathf.Abs (derp.GetComponent<Rigidbody> ().velocity.x) > derp.GetComponent<playerScriptWithAnimation> ().maxMovementSpeed) {
                     derp.GetComponent<Rigidbody> ().velocity = new Vector3 (derp.GetComponent<playerScriptWithAnimation> ().maxMovementSpeed * (derp.GetComponent<Rigidbody> ().velocity.x / Mathf.Abs (derp.GetComponent<Rigidbody> ().velocity.x)),
                                                                           derp.GetComponent<Rigidbody> ().velocity.y,
                                                                           derp.GetComponent<Rigidbody> ().velocity.z);
                 }*/
             derp.transform.position += derp.transform.TransformDirection(Vector3.forward) * (1f/100) *derp.GetComponent<playerScriptWithAnimation>().movementForce;
         }
     }
 
     // OnStateExit is called when a transition ends and the state machine finishes evaluating this state
     override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
         if (derp != null){
             derp.GetComponent<playerScriptWithAnimation> ().characterState = "stand";
             if(derp.GetComponent<playerScriptWithAnimation>().mount != null)
             {
                 derp.GetComponent<playerScriptWithAnimation>().mount.GetComponent<Animator>().SetBool("Moving",false);
                 derp.GetComponent<playerScriptWithAnimation>().mount.localEulerAngles = new Vector3(0f,45f,0f);
             }
         }
         derp.GetComponent<Rigidbody> ().useGravity = true;
     }
 }











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

1 Reply

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

Answer by orangeflame · Dec 30, 2015 at 06:19 PM

ANSWER: I'm an idiot that forgot to include time.deltaTime in my position update statement. -_- sorry for bothering all of you.

how I should have wrote the statement:

  derp.transform.position += derp.transform.TransformDirection(Vector3.up) * (1f/50)*derp.GetComponent<playerScriptWithAnimation>().jumpForce * Time.deltaTime;
Comment
Add comment · 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

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

32 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

Related Questions

Unity windows build exit before asset import 0 Answers

Object position doesnt change in Build but does in Scene/Editor Game 0 Answers

Error when trying to use classes "UnityEditor.PlayerSettings" and "UnityEditor.AspectRatio" 0 Answers

Start, update, OnTriggerEnter and awake functions greyed out when updated from unity 2019.2.4 to unity 2020.1 0 Answers

Error when building in WebGL: "UnityEditor.BuildPlayerWindow+BuildMethodException: 2 errors" 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