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
2
Question by Zeoli · Mar 28, 2017 at 11:04 AM · rigidbody2dupdatefixedupdatescript execution order

Can the Script Execution order be adjusted for FixedUpdate()?

The reason I am asking this is that I have a Player, a Bow and an arrow. the bow follows the arrow and is placed a distance away from the player in the direction of the mouse and rotated to face the mouse. the arrow is spawned by the bow and is held in place at the bow's location and rotation.

The issue is that when the player moves, this causes the bow to move to the last frame's location of player, the same happens for the arrow... so its like I have rubber banded the three objects together as opposed to gluing them together.

can I update the player location, then bow then arrow in the same frame so they are all in the same location when the frame goes to render?

or am I simply going about this all wrong?

Comment
Add comment · Show 1
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 _dns_ · Mar 28, 2017 at 03:02 PM 0
Share

Hi, to solve this kind of dependencies, one solution is to have a "master object", or a "manager object" that just simply call some FixedUpdate-like functions on other objects in the order you want. e.g. during Player's FixedUpdate, call Bow.$$anonymous$$yFixedUpdate then Arrow.$$anonymous$$yFixedUpdate, or any order needed to manage positions dependencies.

Edit: Well, re-reading your question: maybe you want to have the bow child of the player, and the arrow child of the bow, then you don't have to update position as a child will follow the parent's position. If you need to shoot the arrow, you can detach it so it has it's own life in the "World space".

3 Replies

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

Answer by Zeoli · Mar 29, 2017 at 08:11 AM

I like the answers/suggestions given but in this case I wanted to keep the bow separate. reordering the execution sequence did not work.

I fixed this solution and will state what I did so that others may find this useful.

I ended up rewriting the movement code for the bow and arrow along with the shooting. what I ended up with is that when the player is moved, in the player's fixed update where we move the player, we also call Bow.Move(Vector3 position, Quaternion rotation). this function updates the bow's location and rotation but also calls Arrow.Move(Vector3 position, Quaternion rotation) if the arrow had not been fired.

now, all movement that the bow and arrow do, is actually executed during the fixed update for the player.

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
avatar image
1

Answer by eddyb · Dec 19, 2019 at 10:48 PM

For the record, I'd just like to add here that, yes, the "script execution order" settings also affect FixedUpdate() order, not just Update().

I was looking for the answer to that and saw conflicting answers, and Unity's docs don't explicitly say one way or the other, so I just tested it (in 2019.1) and it works as one would hope.

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
avatar image
0

Answer by AurimasBlazulionis · Mar 28, 2017 at 03:10 PM

If Script Execution Order in the Edit panel does not solve the issue, then the solution is rather simple: update the positions in LateUpdate. Or you just set up the execution order the wrong way. Try both. Would be great to see your execution order tab.

Comment
Add comment · Show 1 · 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 Commoble · Mar 28, 2017 at 07:04 PM 0
Share

The problem with LateUpdate is that it's part of the Update (frame) cycle, not the FixedUpdate (physics) cycle.

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

67 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

Related Questions

My character won't stop jumping!!! 1 Answer

Rigidbody2d.MovePosition on Update vs FixedUpdate 1 Answer

Checkibg Rigidbody2d and component problems 0 Answers

How do I convert this into Fixed Update for physics and Update for inputs? 0 Answers

How to restrict rotation properly 2 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