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 smirlianos · Oct 23, 2012 at 04:22 PM · camerajavascriptgameobjectpositionjava

Change Position of an object

I have this script, but I want the object to move slowly, not instant. I tried with * Time.deltatime, but it doesn't work. How can i do that??

  var destination : Transform;
 var destination2 : Transform;
  var firstperson : boolean;
  
  function Update () {
  
  if (!firstperson)
  {
      if(Input.GetButtonDown("Cam"))
      {
          transform.position = destination.position * Time.deltatime;
          firstperson = true;
      }
 }
  
  if (firstperson)
  {
     if(Input.GetButtonDown("Cam2"))
     {
          transform.position = destination2.position;
          firstperson = false;
  }
  }
  
  
  }
Comment
Add comment · Show 4
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 Noah-1 · Oct 23, 2012 at 04:24 PM 0
Share

Next time please google your question, this has been answered many times: http://answers.unity3d.com/questions/187588/move-from-one-point-to-another.html I hope it helps

avatar image smirlianos · Oct 23, 2012 at 06:56 PM 0
Share

thanks, but this is for pingpong. I want to do it only one time

avatar image smirlianos · Oct 23, 2012 at 07:11 PM 0
Share

if i use ping pong it does it continiously, I'm noob, sorry!!!

avatar image smirlianos · Oct 24, 2012 at 01:06 PM 0
Share

any help??

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Noah-1 · Oct 23, 2012 at 07:45 PM

Ok then, Vector3.Lerp should do the trick:

Create an empty gameObject for start point, other for end point and assign them in the inspector.

 var start : Transform;
 var end : Transform;
 
 function Update () {
     transform.position = Vector3.Lerp(start.position, end.position, Time.time);
 }

hope that helps you, and don't apologize for being a "noob", everyone was one before. If you want it to be slower you can simply divide time (Time.time/2).

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 smirlianos · Oct 24, 2012 at 11:26 AM 0
Share

Thanks it worked! But when I add an Input.... itgoes immediatly from one point to another

var start : Transform; var end : Transform;

function Update () { if(Input.$$anonymous$$ouseButtonDown(1)) { transform.position = Vector3.Lerp(start.position, end.position, Time.time); } }

avatar image smirlianos · Oct 24, 2012 at 12:13 PM 0
Share

how can i prevent that???

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

11 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

Related Questions

How to tell if 2 blocks are next to each other in a 2d game? 1 Answer

I want to put main camera floating 0 Answers

How can I get exact screen position of 3D game object in front of camera while using cardboard in VR game? 1 Answer

Locating Position of Object not Working? 2 Answers

How Can I Stop Rotation From This Script? 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