#weird wheels

1 messages · Page 1 of 1 (latest)

stark creek
#

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)

willow lintel
stark creek
#

vehicle > vehicle script > wheel collider > suspension spring (assuming this is joint spring based on the documentation) > damper / spring

willow lintel
#

and you can read the values fine right?

#

it only does the underline when you try setting it?

stark creek
#

correct

willow lintel
#

so weird

stark creek
#

i'm running unity 2021.3.7f1, could that play part in it?

willow lintel
#

maybe try separating them

var a = harvester.GetComponent<vehicleController>();
var b = a.L1w;``` until we reach the end so we know where it breaks
willow lintel
stark creek
#

im not following?

willow lintel
# stark creek 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

stark creek
#

it worked

#

rest of code is unmodified, I just added that at the very end

willow lintel
# stark creek

remove the var d = i accidentally added that, but i’m suprised it’s not complaining

stark creek
#

it complained that it was unnessecary assignment of var d

#

but that was it

willow lintel
stark creek
willow lintel
stark creek
#

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?

willow lintel
stark creek
stark creek
willow lintel
stark creek
willow lintel
#

you need to break up that long line, it won’t let you modify it all on one line

willow lintel
# stark creek

here’s what it should look like

var jointSpring = harvester.GetComponent<vehicleController>().L1w.suspensionSpring;
jointSpring.spring = 10;
jointSpring.damper = fd;```
stark creek
#

ah

#

so it doesn't like that many things going on in one line?

willow lintel
#

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

stark creek
#

if you feel up to it, whats the difference?

willow lintel
#

this explains why it’s a big deal, and it wouldn’t have happened if it was a class instead of a struct

willow lintel
stark creek
#

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

willow lintel
willow lintel
# stark creek if you feel up to it, whats the difference?

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 its a struct, i only get a copy of the values
stark creek
#

oooo

#

okay

#

that makes sense

willow lintel
#

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

stark creek
#

your good, it makes sense lol

#

it is like

#

2am

willow lintel
#

yeah i gtg to bed

stark creek
#

alright, thank you for the help, it is greatly appreciated!

#

have a good night

willow lintel
#

have a nice night UnityChanSleepy