Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 SentokaioStudios · Mar 03, 2021 at 06:33 PM · translatetime.deltatime

different Time.deltatime speed when playing the game build

Hello there! I'm having a little trouble using the Time.deltaTime function.

I am making a rhythm game in unity, and I made a script for delivering notes to the player. So I've used the Time.deltaTime function in the transform.Translate line, but it doesn't seem to work as it should.

In the unity build, the cubes move slightly faster than in the unity test

Here's my script

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class MouseCubeClick : MonoBehaviour
 {
     public AudioSource ClickSound;
     public Vector3 Cube;
     // Start is called before the first frame update
     void Start()
     {
         
     }
 
     // Update is called once per frame
     private void OnMouseOver()
     {
        
                 
                 
      if (Input.GetMouseButtonDown(0) || Input.GetButtonDown("ClickNotesButtons"))
      {
         Destroy(this.gameObject);
         ClickSound.Play();
      }
          
     }
 
 
 
     private void FixedUpdate()
     {
         transform.Translate(Cube * Time.deltaTime);
         
     }
 }
 

I would really appreciate it if anyone could help!

Thank you!

Comment
Add comment · Show 6
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 HoweToGaming · Mar 03, 2021 at 08:27 PM 0
Share

Don't know why but something is telling me it needs to be in Update not FixedUpdate.

avatar image SentokaioStudios HoweToGaming · Mar 03, 2021 at 09:58 PM 0
Share

ok, I'll test it out!

avatar image SentokaioStudios HoweToGaming · Mar 03, 2021 at 10:02 PM 0
Share

Update @HoweToGa$$anonymous$$g :

Your suggestion, sadly, has not worked :(

avatar image unity_ek98vnTRplGj8Q SentokaioStudios · Mar 03, 2021 at 10:23 PM 0
Share

You definitely have a problem in your original script, which is that you are using Time.deltaTime inside of FixedUpdate instead of update. Time.deltaTime is just the time in seconds since the last Update cycle ran, but FixedUpdate does not run at the same rate as Update.


The solution is either to use Time.fixedDeltaTime instead, or to keep Time.deltaTime and move over to Update. It is weird that this didn't work for you though. I suggest trying again or trying Time.fixedDeltaTime.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by SentokaioStudios · Mar 03, 2021 at 11:32 PM

link text

Basically, the notes are being delivered earlier in the Unity Build, and not in sync with the music, like the Unity test

Comment
Add comment · Show 7 · 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 SentokaioStudios · Mar 03, 2021 at 11:33 PM 0
Share

@unity_ek98vnTRplGj8Q @HoweToGa$$anonymous$$g

avatar image unity_ek98vnTRplGj8Q · Mar 03, 2021 at 11:42 PM 0
Share

I played the videos side by side and it looks to me like the cubes are moving at the same speed. I can't hear the audio so I don't know how far it's off, but could it just be an audio syncing issue between the cubes spawning and the music? How do you currently sync the two?

avatar image SentokaioStudios unity_ek98vnTRplGj8Q · Mar 03, 2021 at 11:47 PM 0
Share

I sync them manually, I put the audio in a separated GammeObject, and I create the cubes separately. You might not hear the audio but trust me, it's out of sync @unity_ek98vnTRplGj8Q

avatar image unity_ek98vnTRplGj8Q SentokaioStudios · Mar 04, 2021 at 12:00 AM 0
Share

So when you say you sync them manually, you mean you say "Ok at 10 seconds I am going to spawn this cube and at 10.5 seconds I am going to spawn this cube"? If so, how are you guaranteeing that the start of the cube spawner timer corresponds with the start of the audio playing? Could that be the issue?

Show more comments

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

115 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

Related Questions

transform.Translate by Time.deltaTime 2 Answers

I need to travel the same distance in less than 1 second 1 Answer

Issues with Translating Time.Deltatime 1 Answer

how to move an object (noob) 2 Answers

Problem Javascript to C# 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