Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 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 /
  • Help Room /
avatar image
0
Question by blitzcloud · Apr 11, 2016 at 11:29 PM · instantiatetransform.positionoffsetmoving platformtransform.parent

How to instantiate exactly on the requested place with 0 offset.

I'll cut to the chase, i've been creative on the ways to make it work, but none of them do.

I'm doing a sidescroller runner game and as the sets get instantiated, they get instantly put into a container that moves all the items inside. this helps both having organized hierarchy and just one item carrying the transform.position movements instead of all the children in a per object basis.

The problem is that these objects are moving and the check is done in update method, giving some discrepancies as to what the actual position was -> where it will instantiate. Given that the object is moving, a one frame difference when spawning causes a few units of offset which I cannot allow. Why can't I allow it? because it's simply not the right choice.

One of the methods was calculating the delay, still shows offset, even though it might be less.

Another method was to calculate the offset given the game speed using the framecount, didn't work either, because apparently it doesn't see any difference in frames, meaning it wasn't actually done in the next frame.

Now I tried another approach, what if I don't calculate when instantiating itself, but rather when it's already all parented and then I move the container to the last endpoint (meaning the gizmo that I spawn to see where the set ends onscreen). Hey, I think I got it, nope... there's still an offset. How is it possible that I have an offset if I'm telling it to move exactly to that position?

Given that right now i'm dry on ideas as to how to make it work, I'll just put the problem most possible cause: it's all continuously moving. So what I'm asking is which way would it be appropiate so a transform.position kind of movement does not cause a value offset when I literally tell another object to move to that precise object position.

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 blitzcloud · Apr 11, 2016 at 11:38 PM 0
Share

By the way when I'm talking about an offset I don't mean anything ridiculously high, but more like 0,1-1,1 units depending specially on the framerate. With an enormous amount of FPS i'd get smaller numbers, while on VSYNC the values tend to offset more.

This is what made me realize it's all in the update method, but I swear that the last method where using transform.position after instantiating the whole set (with correct localpositions for each item inside the parented contained) should've worked.

1 Reply

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

Answer by blitzcloud · Apr 12, 2016 at 12:20 AM

Okay, I think I got it, apparently explaining problems really helps to internalize thoughts sometimes. I don't like my current solution so i'm still open to suggestions to improve it, but currently making a yield waitforseconds worth a second of time previous to the transform.position operation seems to do the trick. it feels like something happens if the operation is too quick in terms of sequential processing.

I don't know wether I should think this is a bug on sequential order of computation and maybe I should report it, then again i'm too amateur to even verify it's a bug and not just my bad coding practices. who knows.

PS: this is no joke, i've been trying to fix this for a month or so, with about 4 attempts to change code. Brb going to buy a rubberduck.

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

60 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

Related Questions

How do I instantiate particles properly,How do I instantiate particles correctly? 0 Answers

How to get the position of a new Instantiated prefab 0 Answers

Creating an instance of a prefab at start? 1 Answer

Wrong position (always 0,0,0) when Instantiate prefab. 1 Answer

How can I change position of instantiate objects (clones)? 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