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
0
Question by kurai · Feb 05, 2013 at 01:12 PM · rigidbodytimeforcefixedupdate

Is time-based update necessary in FixedUpdate?

Hi everyone, given the simple control script

 using UnityEngine;
 using System.Collections;
 
 public class PlayerMovement : MonoBehaviour {
     private float x;
     private float z;
     public float speed=100f;
 
     // Use this for initialization
     void Start () {
         
     }
     
     // Update is called once per frame
     void FixedUpdate () {
         x= Input.GetAxis("Horizontal")*speed*Time.deltaTime;
         z= Input.GetAxis("Vertical")*speed*Time.deltaTime;
         rigidbody.AddForce (x,0,z);
     }
 }

I wonder if multiplying by Time.deltaTime is really necessary when applying forces in FixedUpdate. Shouldn't FixedUpdate already be time-based and not frame based?

Can you clarify this point for me? And plus, do you have any advice for how to improve my code?

Thank you!

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 kurai · Feb 05, 2013 at 01:49 PM 0
Share

Another question on the very same script. I used it on a cylinder moving across a field (it is suspended in the air, without gravity influence). Four static cubic colliders act as walls, defining a simple rectangular bound.

The cylinder has a capsule collider and a physics material with bounciness 1. It has a small mass (0.25) and a little drag (0.01).

Problem is, with speed set at 50, the collider often fails, making the cylinder pass through the wall. I tried to divide the fixed timestamp by half, with no result. The object is quite fast, but it's certainly not a bullet (it is meant to be controlled by the player), so these errors seem quite strange to me.

Is there anything else I can do to improve the collision detection? I tried to set the rigidbody parameter as Continuous Dynamic, with no results whatsoever.

avatar image Dave-Carlile · Feb 05, 2013 at 03:19 PM 1
Share

You need to ask this as a new question.

1 Reply

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

Answer by Dave-Carlile · Feb 05, 2013 at 01:35 PM

It's not strictly necessary, but if you don't do it your speed needs to be in units per fixed frame, rather than units per second. I personally always scale by time so my units can be expressed per second. Also, if you don't scale by time and ever decide to change the fixed update rate then you have to go and modify all your rates if you want everything to continue moving the same speed.

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

10 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

Related Questions

Simple colliding objects are updated a frame late. 0 Answers

adding force every frame to control my ridigbody makes it shake ugly 4 Answers

When is Velocity calculated? 1 Answer

adding drag to a relative force 0 Answers

Trying to move an object when I click my LMB 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