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 Persona · Aug 01, 2010 at 03:45 PM · movementprefabwaypoints

Setting up Waypoints using coordinates for Prefabs

I'm trying to set up a waypoint system for my prefabs to follow once they spawn since you can't place the physical location for the waypoint game objects without them being the already present. I'm using a vector3 as a varible coding the location in. The problem is how to get them to move to that location without suddenly teleporting to it.

Any suggestions on how to move them between two waypoints, loop the movement a few times and then move to a third waypoint?

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 cncguy · Aug 01, 2010 at 09:03 PM

By the sound of it all you want is to use Vector3.Lerp. Have a look in the docs for that.

Basically after your prefab is spawned use Vector3.Lerp to move it from its spawnpoint to the first waypoint. Then pause for a few frames if you want, then Lerp to the next waypoint.

Lerp = linear interpolate

transform.position = Vector3.Lerp(startPoint, endPoint, factor);

startPoint = where the object will be if factor = 0.0

endpoint = where the object will be if factor = 1.0

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 Persona · Aug 02, 2010 at 02:50 AM 0
Share

Is there a way to place that inside the prefab? The Lerp works but there's no way to insert the waypoints into the Prefab if I do.

avatar image cncguy · Aug 02, 2010 at 03:19 AM 0
Share

Is the path of waypoints predefined before your game starts. Or is it deter$$anonymous$$ed at runtime? Either way you can have a script on your prefab that follows a set of way points stored as an array of Vector3's. If they are predeter$$anonymous$$ed before runtime code them in, if they are deter$$anonymous$$ed at runtime then generate them at runtime either on the script that controls the prefab or on another script that passes the information to the script on the prefab via a link to the script.

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

Multiple waypoint solutions 2 Answers

changing the speed of an enemy on key press? 2 Answers

How can I move all prefabs together? 3 Answers

Kind of Lag in movement 2 Answers

Cant move FPS controller 1 Answer


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