- Home /
How to improve the quality on an image game object that is bad when i instantiate it?
I have a sprite game object with an image which i want to instantiate to three positions. I use this
public GameObject people;
Vector3[] positionArray = new [] { new Vector3(10.362f,-2.2677f,0f), new Vector3(15.874f,10.257f,0f), new Vector3(-24.073f, 7.8497f,0f) };
// Use this for initialization
void Start () {
// create an array of points for the people to be spawned
people = GameObject.Find ("Cube");
RandomPlace();
}
// Update is called once per frame
void Update () {
}
public void RandomPlace() {
GameObject obj = (GameObject)Instantiate(people, positionArray[Random.Range(0, 3)],people.transform.rotation);
}
but when the game object is instantiated its quality is not good, kind of pixelated at the edges. What is causing this ? I use unity 4.6
If it looks the same when you display it in your scene as a test while not running the game then it is probably to do with your texture import settings. If so select your texture in whatever folder you have it in and have a play around with the $$anonymous$$ip $$anonymous$$ap, Compression, and Ansio settings to see if that resolves your issue.
(Assu$$anonymous$$g that sprite textures are subject to the same sort of import settings that other textures are, if not apologies...)
I have noticed now that many clones of the GameObject people are created even though I have no loop to create many instances of the game object.
if i pause the scene and I try to move the game object there is another (clone) under it and all these clones distort the original image.
Any ideas?
No, as far as I can tell you are only calling the Instantiate code once from Start(). So you should only be creating one people object...?
Are you calling RandomPlace() from any other scripts at all?
Do you have the script on multiple objects, which may be getting called repeatedly? This would be my best suggestion :/
Answer by Afassolas · Nov 14, 2014 at 06:04 PM
I solved this. It needed to have the script attached to another game object that would instantiate the "Cube", otherwise each new instance of Cube was running the Start() method again and was creating another clone going into an infinite loop.
Your answer
Follow this Question
Related Questions
Checking if object intersects? 1 Answer
Instantiate at run time or previously then make active? 1 Answer
Instantiate as a child? 3 Answers
Instantiate ground/enemies 1 Answer