I was searching a lot in the forums, it´s a great tool for reference, but cannot find the rigth info for this issues:
How can I fix the frame rate so it could run at same speed on different computers? (It currently runs smooth on slow cpu but fast as hell on faster cpu)
How could you make differents intances of a gameobject? (I could make instances with Instantiate, but if i want that every instance fade out after some time, they all act as one, fading at same time, same happens if I try to destroy one of them)
If I try to acces the pixelInset of a GUITexture its says is not accesible. Same with location.x, etc. Is ther any way to access this variables directly?
You don’t want to do that. Look up Time.deltaTime, and use that for all movement. This way everything moves at the same speed on all framerates, but faster computers run more smoothly.
Instantiate does make different instances. How are you accessing them?
Not sure about your other question offhand. Welcome to the forums!
It’s not Unity’s fault, it’s how C# is designed. If you use Unity’s JavaScript, you can just set guiTexture.pixelInset.xMin directly and it’ll just work. There is less typing in general with Unity’s JavaScript.
There are actually a couple of ways to do that, but it’s really not what you want. Pretty much all games basically use a deltaTime-like method, even if you might specify an upper limit (common on consoles). Just multiply all movement by Time.deltaTime, like:
Thanks Jonathan!.. that would help me a lot!
Thanks Eric too, I would use the deltaTime then…
For the instantiation… i have deleted the code for now, because the test were unsuccessful… but it was something like this:
public Circle circle;
void Start () {
//Circle
GameObject circle = GameObject.Find(“CircleOne”);
circle = (Circle)circle.GetComponent(“Circle”);
}
public void CreateCircle(float X, float Y, float Z)
{
Circle circleNew;
circleNew = Instantiate(circle, new Vector3(X,Y,Z), Quaternion.identity));
circleNew.Fade();
circleNew.Kill();
Not sure I quite followed that (like I said, my C# doesn’t amount to much), but I think you want to instantiate an object from a prefab, not from a scene object. In Javascript:
var someObject : GameObject;
function Start() {
var myObject : GameObject = Instantiate(someObject);
// Do stuff with myObject
}
Then in the inspector, you drag the prefab onto the appropriate slot in the script.
You are not instantiating a new object, but the the component from the same object. This must be why when you destroy one of them that all of them die (since you kill the gameObject attached to all of the Circle components).
To make them independent try:
Circle newCircle = (Circle)((GameObject)Instantiate( circlePrefab ) ).GetComponent(typeof(Circle));
Btw, don’t use circle on both your vars (I’m not sure that even works, I think that to work you had to do this.circle = (Circle)circle.GetComponent(typeof(Circle)), but I may be mistaken).