Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 kabehzad · Sep 08, 2015 at 09:19 AM · transformtransform.translate

How do I stop transform.Translate using time?

I am sure this is a basic question. I've only had two classes using Unity and one of our assignments is to...

 There must be at least three moving objects.
 They should not all move the same way.

 **Time must be involved in some way (beyond constant motion) - stop the motion after a certain time, don't start the motion until a certain time, or something else.** 

I just can't figure out how to do the third part. How do I stop the constant motion? Again, only been in class for two days. I'm brand new. Do I use an if statement with time?

Please help. I'd be so grateful. Again, I'm sorry for such a basic question.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by cjdev · Sep 08, 2015 at 10:36 AM

You were on the right track with an if statement, all you'd need to do is check the value of your time variable and move when the time is valid.

 if (time < 5f)
 {
     //Move when time is less than 5 seconds
 }
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 kabehzad · Sep 08, 2015 at 11:24 AM 0
Share

Thank you! I will try this out after work today. @cjdev

avatar image Scribe · Sep 08, 2015 at 11:34 AM 0
Share

Another idea could be setting some axis of motion of the object to:

 $$anonymous$$athf.Sin(Time.time*2*$$anonymous$$athf.PI)

or

 $$anonymous$$athf.PingPong(Time.time, 5)

or

 if(time > 1){
     $$anonymous$$athf.Log(Time.time)
 }

Basically look up $$anonymous$$athf unity... it is useful for non-constant motion!

avatar image
0

Answer by kabehzad · Sep 09, 2015 at 01:00 AM

@cjdev - I'm trying to use the time function but where does it come in the script relative to the rest of the code? It keeps giving me an error.

var speed : float = 5.0;

function Update() {

 transform.Translate(Vector3(0,0,speed) * Time.deltaTime);
 
 } 
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 Scribe · Sep 09, 2015 at 08:41 AM 0
Share

What is the error you are getting, if you copy and paste cjdev's code you will get one because the variable 'time' is unknown to unity, you have to google some stuff or find the useful things in the same Time class as you have already made use of.

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

Limit movement to just forward/backward and left/right 0 Answers

Limit movement to just forward/backward and left/right 0 Answers

transform.Translate() effect is being reverted 0 Answers

Trying to make sliding doors. With transform, but it jumps to position. What am I doing wrong? 1 Answer

Moving an object smoothly over predetermined distance without defining begin and end points 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