public struct Tree
{
public float size;
}
Tree myTree;
public float TreeSize{get{return tree.size;}set{tree.size=value;}}
void FixedUpdate()
{
tree.size += 0.1f;
}
void OnGUI()
{
GUI.Label(new Rect(10,10,300,20),"TreeSize: "+TreeSize);
}
… to note this out, this code i wrote here from scratch, it may not reflect the oddness I get, but rather show what changes I made and It seemed to give me some sort of odd results, for example TreeSize was alot larger in “Code B” than in “Code A”
and there seemed to be some sort of a delay maybe?
Because I’m doing precise simulation over time and The behaviour changed dramatically.
I think we need to see your actual code, because your Code B there won’t compile but hints at some subtle things (like the use of structs, in particular).
well both of the codes are incomplete because they are not in a class, youl have to make scripts in unity and paste these codes over start/update methods.
I just showed the part where I got some strange behaviour.
I’d really like to clear my code in locickal way but I cant do this when the valeus get modifyed in the structs get/set methods.
I’l ltry to write it again and see if I can confirm that using this way I get oddness …again, hopefully i’m wrong
I’m working on car physics, well the problem was that, for some reason my slip angle calcualtions gave 21.41~ + values with structs and get/set approach
but with normal setup it gave 0.13~ so the results were really odd, when normally my car had grip, then with structs get/set I lost grip almost instantly and the car was undrivable. After some tweakinc and careful setup I may have found what caused this, I had a combining function that used slip angles directly from the struct while it was suposed to use the ones defined in the method (tho they were the same, wich is odd if you ask me)
nope it wasnt my function, tho now there was a beter numerical result. But overal the physical behaviour is alot accurate when i use the values outside a struct…
I’m specifically talking about Code B. Lines 8 and 12 both make reference to a variable called ‘tree’ but no such variable is defined in visible scope. There’s a variable on line 6 named myTree, and I suspect that you’ve just named it wrong, but I dare not assume because maybe you have some other ‘tree’ variable in scope in your real code and that’s why this is behaving strangely.
oh lol sorry it was suposed to be tree instead of myTree, it was late when I posted, so yeah, anyway, I think I overcome the issue, but quite dont know how…