I’m starting from scratch to learn programming and one of the things I still can’t get is the passing of parameters. In the example in the picture, I tried to pass the variables declared “CurrentPosition” to the boolean function, but I still don’t get how to do it very well, this parameter stuff is complicated, so I’d like a brief explanation with example (using my code if you wouldn’t mind) on how to solve it. The first picture is the header. The second picture is what I tried to do, with a small text of what I’m trying to do.
Please consider I’m starter at this stuff, I have only 4 or 5 days of programming, so explain like I’m 5 yo. One of the biggest issues I get asking stuff here are the answers some people give like they think I know what I’m doing, when I don’t really have a clue about anything.
The issue I’m having is: “CurrentPosition is undefined”, like if it is not declared.
Things you need to know when it comes to parameters:
a) there is something called parameter scope. It defines where a parameter lives & dies.
If the parameter is defined above the function, on it’s outside or on a higher level like in the header then it’s value will persist when you access it.
If a parameter is defined within a function then it will go out of scope once the function ends and is inaccessible (it gets destroyed). The only way to retrieve an internal variables value from within a function is to pass it into the return value (either directly or in an operation)
b) parameters can be passed via reference with the & symbol. Then you can do changes to the parameter and it will have consequences outside of the function & persist.
c) you can pass parameters via a pointer (the * symbol). This is an address in memory that points to the value of the variable. You can access the value of a pointer via a reference to it.
d) you can pass parameters via a copy (depending on the programming language). Changes done to the passed in parameter will not persist as you are operating on a copy of the parameter. (usually not the most performant as can increase memory consumption)
In your function ShouldPlatformReturn you are passing in a vector and accessing StarPosition & CurrentLocation which I’m guessing are defined in the header as uproperties.
You are not using the return of the function in any way. You should assign the return to a boolean on the left hand side of the function (with an = sign)