#weird wheels
1 messages · Page 1 of 1 (latest)
it would probably be easier if I post the code, I removed some of the empty space and commented out code
not too complicated (yet lol)
vehicle > wheel collider > joint spring > damper
Is that how that code reads?
vehicle > vehicle script > wheel collider > suspension spring (assuming this is joint spring based on the documentation) > damper / spring
and you can read the values fine right?
it only does the underline when you try setting it?
correct
so weird
maybe try separating them
var a = harvester.GetComponent<vehicleController>();
var b = a.L1w;``` until we reach the end so we know where it breaks
no it shouldn’t
if it’s the last one that breaks i’ll go crazy https://docs.unity3d.com/ScriptReference/JointSpring.html
im not following?
I typed out the rest for you, which one does it underline?
var a = harvester.GetComponent<vehicleController>();
var b = a.L1w;
var c = b.suspensionSpring;
var d = c.spring = 10;```
it pretty much separated that long line into a bunch of pieces so we’ll know exactly which one it’s complaining about
remove the var d = i accidentally added that, but i’m suprised it’s not complaining
ok connect the last line to b to form var c = b.suspensionSpring.spring = 10;

spain but the s is silent
I mean, this is just a debug code to begin with
so cleanliness isn't super important
do you think it would work if I just did it like this?
wth does it even return then
.
I got no clue
maybe try this, remove .spring
oh actually it’s just a normal thing: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-messages/cs1612
you need to break up that long line, it won’t let you modify it all on one line
here’s what it should look like
var jointSpring = harvester.GetComponent<vehicleController>().L1w.suspensionSpring;
jointSpring.spring = 10;
jointSpring.damper = fd;```
seems a bit strange why c# wouldn’t let you modify it, but the reason in the doc doesn’t make that much sense to me but i’m sure there’s a reason
omg, i figured it out
JointSpring is a struct that’s why
I thought it was a class, that’s why i was so confused
if you feel up to it, whats the difference?
this explains why it’s a big deal, and it wouldn’t have happened if it was a class instead of a struct
Classes are reference objects, while structs are value objects
so when I have everything prior to "suspensionSpring" that is a reference, but when I add the .spring or .damper to it everything before that is read as a copy of the value that its referencing?
so like, its trying to read a clone of the reference that doesn't exist
everything prior to suspension spring was a class/returned a class. suspensionSpring was a struct meaning it’s an value type object
A struct you are used to is Vector3
Vector3 pos = transform.position;
pos.y = 100;```
If it were a class, assigning it gives a reference to it meaning it would mess with the objects position the instant i modify it. BUT since it’s a struct, i only get a copy of the values
i guess the error is caused by it returning a struct, without copying it to a variable, and then forgetting all about it so when you try accessing variables off of it immediately off of getting it without saving it to a variable it forgot what object you were talking about
gahh i can’t type
yeah i gtg to bed
have a nice night 