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
-1
Question by matta9001 · Jul 15, 2014 at 05:24 AM · javascripttransformtranslate

Transform.Translate change distance and speed

So basically in my experience with transform.translate you can basically choose how fast it goes. For example, transform.Translate (Vector3(-1,0,0) * Time.deltaTime*distance);, if i had a variable called distance it wouldn't change the distance, it would just change the speed on how fast it would go. So basically i have a randomized variable and i want it to go the same speed, but different distances. So should i not use transform.translate or is there something else that i should probably use because i want the same speed but different distances.

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

Answer by Kiwasi · Jul 15, 2014 at 05:28 AM

Distance is a function of speed and time. So if you want the same speed and different distances then you simply need to let the code run for longer.

Comment
Add comment · Show 6 · 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 matta9001 · Jul 15, 2014 at 05:37 AM 0
Share

So how do i change the amount of time the code is running based on a variable. Because i have a randomized variable but i want it to go that distance.

avatar image Huacanacha · Jul 15, 2014 at 05:47 AM 0
Share

Division.

Seriously though you might want to take a look at Vector3.$$anonymous$$oveTowards.

avatar image matta9001 · Jul 15, 2014 at 06:30 AM 0
Share

I dont know if i can do that, because i want the distance changed by the variable, not a given point. I looked at $$anonymous$$oveTowards and it doesn't look likely because i need to make it go left and right. I just need like transform.translate that goes a certain distance based on a variable, the movetowards looks like its based on steps and a pre deter$$anonymous$$ed transform

avatar image Kiwasi · Jul 15, 2014 at 09:39 AM 0
Share

... You should take up stamp collecting, its likely to be a more enjoyable hobby.

However, if your willing to persist, I'm willing to help. There are a number of ways to make code run for a set period of time. I'll show you how to do a custom timer. You should also look up coroutines. The timer shown below will work for 3 seconds. (C#)

 private float timer = 3;
 
 void Update (){
     if (times > 0){
         timer = timer - Time.deltaTime;
         // Do your move function here
     }
 }

avatar image matta9001 · Jul 15, 2014 at 04:59 PM 0
Share

Thanks, I made this question with the $$anonymous$$dset that you could calculate a specific point based on current location and make the object move over time. I didn't really have the $$anonymous$$dset with time, so thanks for giving me that snippit of code it helps even though im using javascript it made me realize what i was doing wrong

Show more comments

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

23 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

Related Questions

Player Transformation 2 Answers

Move an object to a specific point? 1 Answer

How to translate object one movement with script 1 Answer

LookAt transform plus a y value 1 Answer

Move object to raycast point. 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