• 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 Spanker · Nov 17, 2016 at 07:20 AM · 2dunity5transform.position

2D Character appearing in two places for a split second when transforming position

So basically I'm re-spawning a player at a checkpoint and for a split second when it spawns it shows an image of the player somewhere else.

Its a bit hard to explain which is why I had no luck finding an answer for this. But it feels like it spawns somewhere else first and then quickly moves it to the checkpoint or somehow it shows the last frame before dying in a split second before going to checkpoint.

It could be from doing the transform.position too quickly but I even have a delay for the re-spawn and it happens no matter how many seconds I delay it.

This happens in every checkpoint. Here is the code I'm using. I've tried changing the order of the lines a bit and the camera related code but it doesn't seem to solve it. When I run the game frame by frame this issue doesn't happen and it also doesn't happen 100% of the times but most of them.

It's a coroutine called in a normal method.

 public IEnumerator RespawnPlayerCo() {
       
       Instantiate(deathParticle, player.transform.position, player.transform.rotation);
       player.gameObject.SetActive(false);
       cameraMain.isFollowing = false;
       Debug.Log("Player Respawn");
       yield return new WaitForSeconds(respawnDelay);
       player.gameObject.SetActive(true);
       cameraMain.isFollowing = true;
       player.transform.position = currentCheckpoint.transform.position;
       Instantiate(respawnParticle, currentCheckpoint.transform.position, currentCheckpoint.transform.rotation);
    }
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 Gmotagi · Nov 17, 2016 at 10:38 AM

@Spanker Have you tried putting the player.gameObject.SetActive after setting the position on line 10 ? Maybe with a yield return new WaitForEndOfFrame() in between even?

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 Spanker · Nov 17, 2016 at 04:19 PM 0
Share

It worked! It definitely was something with the frames. Thanks for the help!

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

How can a character not move out of box collider's bounds? 1 Answer

Need help in managing sprite transform. 1 Answer

Unable to access rigidbody2d.Velocity? 3 Answers

Set Procedural Cave Generation as child at parent location? 0 Answers

Loading images from AssetBundle 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