Answer by Peter G
'RED' and 'BLUE' are [instance variables][1] (compare to [class/static variables][2]). You need to find the instance to access there values. The easiest way to do that is: var cube = FindObjectOfType(...
View ArticleAnswer by Peter G
If you're accessing `counter` from a member function in the same class that counter is declared in, then you can access it without a type identifier. Otherwise you need to put the class name before you...
View ArticleAnswer by Peter G
If I'm understanding your question correctly, you shouldn't need any other variables. Can you do something like this: int minimumWage; int poverty; function Update () { if(minimumWage < poverty/10)...
View ArticleAnswer by Peter G
A draw call is basically a batch of triangles sent to the GPU for drawing. In general every object with a different material creates another draw call (there are ways of combining draw calls, but...
View ArticleAnswer by Peter G
There's two errors. One of which is causing the compiler, and the other of which is just causing broken behavior. You have to assign the output of `Mathf.Clamp()` to something. `inAirVelocity` is...
View ArticleAnswer by Peter G
The problem is that a mutual conversion exists. To quote the [MSDN page][1] on your error.> In a conditional statement, you must be able to convert the types on either side of the : operator. Also,...
View ArticleAnswer by Peter G
I'm not totally sure that the design of your program makes sense. Your card class is currently working as both the container class for a card, and the enumeration of all the cards in the player's hand....
View ArticleAnswer by Peter G
You have 2 errors. It looks like you are trying to call the constructor to create a new Vector3. The issues is that there are no constructors that take a Vector3 as an argument (you can copy it, but...
View ArticleAnswer by Peter G
I would do something like this: var scoreMultiplier = 5; function Start () { InvokeRepeating( "DecreaseMultiplier", 30 , 30); //You could easily set this up as a coroutine if you wanted variable times....
View ArticleAnswer by Peter G
Moving a character to a point is the same process as moving value to a destination. You find the direction then move in that direction until the offset is less than a specified precision. void Update...
View ArticleAnswer by Peter G
I see what you're trying to do, and it could work. It just seems like a rather circuitous way of doing it. I might try something like this. Vector3 offset = target.position - transform.position;...
View ArticleAnswer by Peter G
You should just be able to add the initial value to the result of `Mathf.Repeat()` var answer = 50f + Mathf.Repeat( Time.time * TimeMultiplier , 50);
View ArticleAnswer by Peter G
You really shouldn't compare floats this way, but the comparison operator is two equal signs: if (StackNum == 1) { }
View ArticleAnswer by Peter G
From my experience, you actually have to get the particles before you can set them. Not every frame, but at least once you need to get some existing particles before you change them and reassign them....
View ArticleAnswer by Peter G
The general equation for linear interpolation is your second one. Output = (1 - t) * Input1 + t * Input2 It can nicely be expanded to higher degrees (see Bezier curves) and vectorized. Just treat the...
View ArticleAnswer by Peter G
It's because whoever wrote the code is writing it into a Vector3. The `?:` (It's called the conditional/ternary operator) is setting the x value of the Vector3. Then the y component is 0, and the z is...
View ArticleAnswer by Peter G
That's probably the easiest way to do it. Yes. The only thing I would worry about is overdraw. Putting a plane over the whole screen essentially means you have to draw every pixel at least twice. So...
View ArticleAnswer by Peter G
It usually means that you have a mesh collider (with attached rigidbody) that isn't totally enclosed or is non-manifold.
View ArticleAnswer by Peter G
Unity does not include any built-in functionality to implement forcefields, but it provides plenty of tools to set it up. I would set up a system something like this: - Each field source has a function...
View ArticleAnswer by Peter G
I'm a little curious why you are pushing this operation to another thread? But for starters, the delayed execution functionality of `yield` that Unity only works if you call it from `StartCoroutine()`....
View Article