Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 /
This question was closed Sep 07, 2016 at 02:47 AM by alexander11 for the following reason:

Question is off-topic or not relevant

avatar image
0
Question by alexander11 · Sep 05, 2016 at 11:35 PM · c#unity 53doffsetpoints

How do i create objects in between two points with an offset???

Hello i am wondering on how to do this

in Pic1 SEG3, for example i know how to do whats in SEG1/SEG2 with this Vector3 position = controlPoints[i].position + j *(controlPoints[i + 1].position - controlPoints[i].position) / segCount;(For more about the code visit here its an old question i asked about dividing between two points), but i want to know how to do this in SEG3(which we'll come around in second), as you can see in SEG2 when i move it the subPoints will always stay in the center, but i want to know when i move it like in SEG3 that sub points stay specific distance(int distanceCP) away from the controlPoints, would anyone know how to do this??

  • -Pic1 alt text


Here is the code that does SEG1/SEG2.

 public class Points : MonoBehaviour
  {
      public Transform[] points;
      public GameObject GameObj;
      public float GameObjectAmount = 2;
      void Start()
      {
          duplicateObject(GameObj, (int) GameObjectAmount);
      }
      public void duplicateObject(GameObject original, int howmany)
      {
          howmany++;
          for (int i = 0; i < points.Length-1; i++)
          {
              for (int j = 1; j < howmany; j++)
              {
                  Vector3 position = points[i].position + j * (points[i + 1].position - points[i].position) / howmany;
                  Instantiate(original, position, Quaternion.identity);
              }
          }
      }
      void OnDrawGizmos()
      {
      for (int i = 0; i < points.Length - 1; i++)
      {
          Gizmos.DrawLine(points[i].position, points[i + 1].position);
      }
 }
  }


@b1gry4n @Bunny83

capture65.png (105.5 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

1 Reply

  • Sort: 
avatar image
1

Answer by Benjames · Sep 06, 2016 at 03:54 AM

Vec1+(Vec2-Vec1).normalized*distance == what you want I think

Comment
Add comment · Show 5 · 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 alexander11 · Sep 06, 2016 at 06:40 AM 0
Share

Thanks-ish @Benjames but it did not work correctly as you can see in Pic1 SEG1 is what i get, i'm trying to do this in SEG2.

NOTE: I made a mistake in the picture the top one is SEG1

-Pic1 alt text Don't $$anonymous$$d the white spheres in SEG2 i was supposed to erase them


And this is the code i changed.

 Vector3 position = points[i].position + j * (points[i + 1].position - points[i].position) / howmany;

To

 Vector3 position = points[i].position + (points[i].position - points[i + 1].position).normalized * 1f;


EDIT: Look at the post i edited the picture.

avatar image doublemax · Sep 06, 2016 at 11:29 AM 1
Share
 Vector3 position = points[i].position + (points[i+1].position - points[i].position).normalized * 1f;

Benjames' code looks correct, you just had the point order wrong.

avatar image alexander11 doublemax · Sep 06, 2016 at 06:45 PM 0
Share

@doublemax Either way of the point order It still does not get me what i want, i am getting this as you can see in Pic1 with the code, ins$$anonymous$$d of this in Pic2.

  • -Pic1 http://imgur.com/B791VC4


  • -Pic2 http://imgur.com/rml2tL$$anonymous$$

avatar image doublemax alexander11 · Sep 06, 2016 at 06:50 PM 0
Share

Are you referring to the fact that there is only one sphere and the one at the other end is missing? For that one you just have to swap the points in the formula and do it again.

Show more comments

Follow this Question

Answers Answers and Comments

237 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 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 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 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

Adding segments in missing spots 1 Answer

How do i Instantiate sub-Points with in Multiple Points?? 1 Answer

What is Matrix4x4? 2 Answers

Hello i am having some trouble converting a JS to a C# script. 1 Answer

How can I generate a up facing quad mesh with adjustable res? 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