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 mmangual_83 · Dec 28, 2013 at 03:13 PM · c#itween

How to reset an game object's position

I am working on a piece of code using itween that move's a game object left and right and I keep it in a ping pong loop. After I press a button, it calls the stop by name function and the object stops (as it should) but it stops at the last position and I want to set it to a specific position. I tried using gameobject.transform.position = new vector3(0,0,0) and it works perfectly. However, it restrains the object from moving again. Is there a way to arrange the game object's position the way I want it? Thank you in advance.

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
1
Best Answer

Answer by GoCatGoGamesLLC · Dec 28, 2013 at 03:37 PM

Have you tried creating a variable to hold the "at rest" position instead of just setting the transform? That way it could either be ping-ponging OR set to its default position, allowing you to transition between the two.

I don't use iTween much, so apologies if I steer you wrong.

Comment
Add comment · Show 4 · 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 mmangual_83 · Dec 28, 2013 at 03:44 PM 0
Share

how would i set the at rest? Is it as simple as just doing it like this: vector3 atRest = new vector3(0,0,0);

avatar image GoCatGoGamesLLC · Dec 28, 2013 at 03:59 PM 0
Share

I would have two states for the object: pingponging and at rest. On your button click, you could set a boolean atRest to be true, giving it your at rest position. Otherwise atRest is false.

Unfortunately I am on my iPad and can't effectively type or copy/paste useful code.

avatar image mmangual_83 · Dec 28, 2013 at 04:14 PM 1
Share

That's quite alright, you have dome quite enough for me. I have it working now. It was a mixture of finding the answer as I was writing the question and then the answer you gave me just made it a LOT clearer. So Thank you; full points to ye!

avatar image GoCatGoGamesLLC · Dec 28, 2013 at 04:21 PM 1
Share

Good to hear! Good luck!

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

19 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

Related Questions

Multiple Cars not working 1 Answer

Rotating an object using itween 1 Answer

Waiting between pingpong loops 2 Answers

using itween to move objects in the 6 degrees of freedom 1 Answer

Using iTween for custom variables 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