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 /
avatar image
0
Question by Brouwer71 · Dec 27, 2017 at 11:37 AM · pathinstantiate prefabpathfollowing

Instantiate Objects Along a curved (circulair) Path

Starting to learn coding I am trying to instantiate (or create) objects along a specific path. I found the code from " Arkham Interactive" helpful to create a Bezier curve. I can move an object along this path correctly but I am now tryring to instantiate objects along this path (using waypoints but trying to get them next to eachother). It works for the straight part but I cannot seem to get the correct angle at the sloped part. What I am trying to achieve is very similar to what has been shown in CatLike coding "Curves and Splines" (but this curve does not allows removal of points which make it hard to control). Does anyone have any ideas how (or guide me in the right direction) to instantiate (create) objects along a path consisting of waypoints (5 in this case but could be a random number) that has a curved shape and possibly have them all move around this path. I know the position of the waypoints (array) and I was testing to see if it would would be able to follow the curve using the code from Andeee (creating script for every two waypoints):

 var startPoint: Vector3;
 var endPoint: Vector3;
 var numObjects: int;
 var objects: Transform[];
  
 function Start() {
     for (i = 0; i < numObjects; i++) {
         var newObj = Instantiate(objects[Random.Range(0, objects.Length)]);
         newObj.position = Vector3.Lerp(startPoint, endPoint, (i * 1.0) / (numObjects - 1));
         newObj.transform.LookAt(endPoint);
     }
 }

But this places the objects at a weird angle at the end of the waypoint (not using a symmetrical shape). I attah two images, the first one shows the original object in the red circle and the direction of the objects to be created (black arow). The blue arrow shows the results I would like to achieve but do not seem to be able. One aspect that I see is shown in the other image in the orange circle (assume it has something to do with the origen point but I am not sure). I understand that is most likely an easier problem to solve for experienced coders (which I a not) but any guidance is really appreciated. Thanks.

171227pathinstantiate.jpg (44.5 kB)
171227pathinstantiate1.jpg (28.4 kB)
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

0 Replies

· Add your reply
  • Sort: 

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

71 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 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 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 avatar image avatar image

Related Questions

Problem with moving through waypoint 0 Answers

How to get an Object to move physically correct (velocity) 1 Answer

Object following the path 3 Answers

How do I get my patrolling enemies to go back to the patrol point they had not gotten to because they chased the player? 1 Answer

iTween nodes bug PLEASE HELP! 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