Getting an Error when I try to set surfaceEffector2D in the code

following the course I define surfaceEffector2D

also following the course I change the speed within update
image

however I’m getting this exception

and on upkey press I am getting this exception

Also, everything seems to be defined correctly in the inspector
image

image

Ah, looks like you’re defining a new variable inside of the Start method. Try removing the SurfaceEffector2D from in front of surfaceEffector2D and it should work.

I’ve run into this same issue before and banged my head against the wall trying to figure it out. :slight_smile:

Here’s some additional info about this issue - it’s Java but it’s very similar to C# - Instance Variable and Local Variable with Same Name

Ah I feel silly now
Thanks, Solved now

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms