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 Wes 1 · Nov 21, 2010 at 12:25 AM · transformvector3

How can I get it from point b to point c

I have a sphere, right now I have it traveling to the position of a cube. how do I get it to travel to the position of another cube only after hitting the first one? here's my script.

var start : Transform; var end : Transform;

 function Update () {
 transform.position = Vector3.Lerp (transform.position,end.position,Time.time);

}

I'm assuming I would be using an if state, maybe something like: If(GameObject is here) {move it here}

That's just an un-educated guess though.

UPDATE**

Okay I made a collision script, and though I get no errors it doesn't seam to do anything. My objects have rigid bodies but no colliders, here's the script.

var start : Transform; var end : Transform; var end2 : Transform;

function Update () { transform.position = Vector3.Lerp (transform.position,end.position,Time.time);

}

function OnCollisionEnter(collision : Collision) { if(collision.gameObject.name == "hit") transform.position = Vector3.Lerp (transform.position, end2.position,Time.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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Lance · Nov 21, 2010 at 12:33 AM

Try Lerping from the "start" position you set up instead of the transform.position you have in code now.

Update

Apologies. I think I know what you mean now, you're wanting to queue the action of movement. Unless you have some other system determining your "next" position, I would think the easiest way would be to have a script that checks for the moving object to collide with it, then has a moveTo property (Vector3 or GameObject) assigned to it that indicates where to move next. Then place a movement script on the moving object to check against whether your current position is where you're supposed to be; if not, Lerp to it.

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 Wes 1 · Nov 21, 2010 at 12:58 AM 0
Share

Yeah, a collision detection script crossed my $$anonymous$$d. However I'm doing this sphere cube stuff because I'm trying to learn all I can about vector3 and translation at the moment, so I wanted to try to do it using that kinda stuff.

avatar image
0

Answer by Uriel_96 · Nov 21, 2010 at 12:33 AM

try this script:

transform.localPosition.x = other.localPosition.x;

or you also can use this one if you want the entire object:

transform.position = other.position;

and if you want to do it for some time you use Time.deltaTime * speed;

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 Wes 1 · Nov 21, 2010 at 12:55 AM 0
Share

Sorry, I'm a bit of a slow learner. Are you saying use that script in an if statement, like "If(transform.localPosition.x = other.localPosition.x;)
??

avatar image Uriel_96 · Nov 21, 2010 at 01:06 AM 0
Share

No, the localPosition has his name says is to the position the object you have to get to a position, so its just say to the object position gets to the other object and use the Time.deltaTime to go in a specific time to the object and its the same with the transform.position(use the position is better than use the localPosition)

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

No one has followed this question yet.

Related Questions

What is wrong with my zipline script? 2 Answers

Why does this placement script not work? 1 Answer

fixed distance for Vector3.moveTowards ? 1 Answer

Vector3 Projection 2 Answers

Vector3 Transform.Position Not Working 2 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