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 autumn_737 · Mar 18, 2012 at 02:43 AM · translationdestination

Changing destination on a move object script

Hi, I'm trying to make a code that puts one object from one position to another, I have this code but I cannot change the end destination to my liking and I'm struggling to understand it. Any help would be appreciated. :)

  enum MoveType {Time, Speed}
 
 static var use : MoveObject;
 
 function Awake () {
     if (use) {
         Debug.LogWarning("one only");
         return;
     }
     use = this;
 }
 
 // translates an object's position to another
 function Translation (thisTransform : Transform, endPos : Vector3, value : float, moveType : MoveType) {
     yield Translation (thisTransform, thisTransform.position, thisTransform.position + endPos, value, moveType);
 }
 
 // smoothly moves and object from a point to another
 function Translation (thisTransform : Transform, startPos : Vector3, endPos : Vector3, value : float, moveType : MoveType) {
     var rate = (moveType == MoveType.Time)? 1.0/value : 1.0/Vector3.Distance(startPos, endPos) * value;
     var t = 0.0;
     while (t < 1.0) {
         t += Time.deltaTime * rate;
         thisTransform.position = Vector3.Lerp(startPos, endPos, t);
         yield;
     }
 }
 
 // rotates to a certain limit given speed and time values
 function Rotation (thisTransform : Transform, degrees : Vector3, time : float) {
     var startRotation = thisTransform.rotation;
     var endRotation = thisTransform.rotation * Quaternion.Euler(degrees);
     var rate = 1.0/time;
     var t = 0.0;
     while (t < 1.0) {
         t += Time.deltaTime * rate;
         thisTransform.rotation = Quaternion.Slerp(startRotation, endRotation, t);
         yield;
     }
 }

thanks for your time.

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 ByteSheep · Mar 18, 2012 at 04:13 AM

After a quick glance it looks like endPos is the Vector3 variable that you need to change to set a different end destination.. Your question is a bit unclear - have you been able to change the end position but just not to the correct position, or are you having trouble change it's value altogether?

Comment
Add comment · Show 2 · 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 autumn_737 · Mar 18, 2012 at 09:32 AM 0
Share

I gathered that end pos was somewhat the destination points, I just don't know how to re enter the points to put in a new target.

Sorry I couldn't make it clearer. So I want to put in 'object_des' where the end pos variable to make it read that information ins$$anonymous$$d. :)

avatar image ByteSheep · Mar 18, 2012 at 03:35 PM 0
Share

You could try just setting

endPos = object_des;

That way the endPos variable will be set to the same destination as object_des..

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Changing destination on a move object script 0 Answers

Objects Going to 0, 0, 0 Coordinates 3 Answers

Camera at wrong place after build 1 Answer

How to translate car wheels to suspension? 1 Answer

How Translation with a fils txt and script I18n ? 0 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