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 /
  • Help Room /
avatar image
0
Question by sportente · Mar 09, 2016 at 09:46 AM · c#instantiatepositiontransform.position

How can I change position of instantiate objects (clones)?

I created a series of sphere clones in my game. After that I adapted the scale so that they appear smaller. However, now there is a gap between these spheres ... and I would have to change the position of this instatiate game objects. I changed my code already exactly at this position but nothing happens. So please I need your help! How can I do this? I would have very small spheres which are located near together.

Here the code:

 using UnityEngine;
 using System.Collections;
 
 public class SineWave : MonoBehaviour {
 
 
     private GameObject plotPointObject;
     private int numberOfPoints= 100;
     private float animSpeed =1.0f;
     private float scaleInputRange = 8*Mathf.PI; // scale number from [0 to 99] to [0 to 2Pi] //Zahl vor Mathf, Anzahl Bön 
     private float scaleResult = 2.5f; // Y Achse Range 
     public bool animate = true;
 
 
 
 
     GameObject[] plotPoints;
 
 
     // Use this for initialization
     void Start () {
 
         if (plotPointObject == null) //if user did not fill in a game object to use for the plot points
             plotPointObject = GameObject.CreatePrimitive(PrimitiveType.Sphere); //create a sphere
 
 
         //add Material to the spheres , load material in the folder Resources/Materials 
         Material myMaterial = Resources.Load("Materials/green", typeof(Material)) as Material;
         plotPointObject.GetComponent<MeshRenderer> ().material = myMaterial;
 
 
         //change the scale of the spheres 
         //plotPointObject.transform.localScale = Vector3.one * 0.5f ;
         plotPointObject.transform.localScale -= new Vector3(0.5f,0.5f,0.5f);
 
 
         plotPoints = new GameObject[numberOfPoints]; //creat an array of 100 points.
         //plotPointObject.GetComponent<MeshRenderer> ().material =Material.Load("blue") as Material
 
 
         //plotPointObject.transform.localScale -= new Vector3 (0.5F, 0.5F, 0.5F); //neu: change the scale of the spheres
 
 
         for (int i = 0; i < numberOfPoints; i++)
         {
             plotPoints[i] = (GameObject)GameObject.Instantiate(plotPointObject, new Vector3(i - (numberOfPoints/2), 0, 0), Quaternion.identity); //this specifies what object to create, where to place it and how to orient it
 
         }
         //we now have an array of 100 points- your should see them in the hierarchy when you hit play
         plotPointObject.SetActive(false); //hide the original
 
     }

And here a screenshot of how it looks like for the moment:

link text

screenshotrtfd.zip (13.8 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

· Add your reply
  • Sort: 
avatar image
0

Answer by richardgengle · Sep 18, 2020 at 06:56 PM

@sportente heres what i am using... and its kinda klunky, in that simulation speed is poor for many particle/clone water simulation...remember to ASSIGN THE RIGIDBODY TO YOUR OBJECT TO CLONE, and also to DRAG IT TO THE PLACE ON THE SCRIPT WHERE THE "PUBLIC" SHOWS UP.

==== // before start routine

public Rigidbody2D tearrb;
float x=0;// pick values of x, dx, y, dy to whatever you need
float y=0;
float dx=1;
float dy=1;// pick values of x, dx, y, dy to whatever you need

// in update routine
Rigidbody2D clone;
x=4; // pick values of x, dx, y, dy to whatever you need
y=4;
dx=1; // pick values of x, dx, y, dy to whatever you need
dy=1;


clone2 = Instantiate(tearrb, new Vector2(x, y), tearrb.transform.rotation);
clone2.position += new Vector2(dx, dy);
Destroy(clone2, 10f); // remove this line if u dont want to destroy/remove your clone
=== tell me if u can get something working ;]

Comment
Add comment · 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

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

134 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

Related Questions

Wrong position (always 0,0,0) when Instantiate prefab. 1 Answer

Game Object doesn't instantiate at Mouse Position 3 Answers

Photon Player instantiate position 1 Answer

How do you pick up an instantiated object? 1 Answer

Change player position based on loaded scene 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