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 unity_TQ4BNk5-bqnogg · Jan 14, 2019 at 08:59 PM · lerplookatmove an objectmovetowardsaxes

Move n-Objects in a row to a point "B", looking at it

Hi, I have already figured out how to place a number of n cubes, all looking at the same point B. But the issue here is, that they don't spawn in a row, which is also looking at point B (row-direction to B). The Position of Point B is variable before runtime. I already thank you in advance!

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class Rings : MonoBehaviour {
 
     float lerptime = 5;
     public float currentLerpTime = 0;
     public Transform ring, RingClone;
     public GameObject PointA, PointB, RingPrefab;
     Vector3 startPos;
     Vector3 endPos;
     public int Kapaz;
     public int i = 0;
     public int capacity;
     public string KnotA, KnotB;
     int n;
 
     public string KanalObjekt;
 
 
     void Start() {
       
     }
    
     void Update()
     {
         //Test
         CreateRings();
     }
 
     public void getNodes(string A, string B)
     {
         KnodeA = A;
         KnodeB = B;
     }
     
     //capacity = Number of Cubes to be spawned
     public void getCapacity(int capacity)
     {
         Kapaz = capacity;
     }
 
 
     public void CreateRings()
     {
         //capacity = Number of Cubes to be spawned
         getCapacity(5);
         //Nodes
         getNodes("Node A", "Node B");
 
         PointA = GameObject.Find(KnodeA);
         PointB = GameObject.Find(KnodeB);
 
 
         //Ring = Parent Cube
         ring = transform.Find("Ring");
         
      
         ring.LookAt(PointB.transform);
         
         
         //RingPrefab = Child Cubes (Parent = Ring)
         RingPrefab = GameObject.Find("RingPrefab");
 
         Vector3 ringpos = ring.transform.position;
         
         if (i != Kapaz)
         {
         
             for (n = Kapaz; n > 0; n--)
             {
                 Vector3 clonepos = new Vector3(ringpos.x + (0.25f * n) , ringpos.y, ringpos.z);
                 
                 Instantiate(RingPrefab).transform.parent = ring.transform; 
                 
                 RingClone = ring.transform.Find("RingPrefab(Clone)");  
                 RingClone.name = n.ToString();                    
                 RingClone.transform.position = clonepos;                
                 RingClone.LookAt(PointB.transform);
 
 
             }
 
             //only executed if kapaz has been changed
             i = Kapaz;
         
          }
          
          
         //move row from A to B
         
         startPos = PointA.transform.position;
         ring.transform.position = startPos;
         endPos = PointB.transform.position;
 
 
 
         currentLerpTime += Time.deltaTime;
         if (currentLerpTime >= lerptime)
         {
             currentLerpTime = lerptime;
         }
 
         float perc = currentLerpTime / lerptime;
 
 
         ring.transform.position = Vector3.Lerp(startPos, endPos, perc);
 
         //cube back to point A
         if (ring.transform.position == PointB.transform.position)
         {
           
             currentLerpTime = 0;
         }
 
     }
 
 }
 
Comment
Add comment · Show 2
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 unity_TQ4BNk5-bqnogg · Jan 14, 2019 at 09:04 PM 0
Share

currently it's looking like this (Point B is the sphere, Point A the big cube)

unityissue.png (174.1 kB)
avatar image Cornelis-de-Jager · Jan 14, 2019 at 09:12 PM 1
Share

Can you please draw an image in paint of what you would like it to look like

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by unity_TQ4BNk5-bqnogg · Jan 14, 2019 at 09:28 PM

alt text


unityissue1.png (163.9 kB)
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 unity_TQ4BNk5-bqnogg · Jan 14, 2019 at 09:31 PM 0
Share

So the red cubes should basicly be behind the blue one, also (as the blue cube) looking at Point B (the sphere).

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

99 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

Related Questions

Leading Reticle 0 Answers

How to let navMeshAgent smoothly aim/rotate smoothly to two different GameObjects,How to let navMeshAgent smoothly aim to two different GameObjects 0 Answers

Smooth swapping my game object 0 Answers

3 coroutines to ease in lerp, MoveToward steady pace, and ease out lerp 0 Answers

MoveTowards is not working with RectTransform component 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