14-02-2019, 04:18 PM
(14-02-2019, 04:05 PM)Richard Wrote: Hello. I learned a little.
In the website(http://obi.virtualmethodstudio.com/tutor...icles.html), I think you do not declare "solver". How did you declare in that script?
Hi there,
The code in most snippets assumes the solver/actor are already declared. Unless the sample code is an entire script, it is assumed these variables come from your own code.
There's many ways to get a reference to a solver. If you already have an actor, you can obtain the solver that manages it:
Code:
ObiSolver solver = actor.Solver;
You can also declare a public variable in your script, and fill the reference from Unity's inspector:
Code:
public class YourScript : MonoBehaviour
{
public ObiSolver solver;
//.... rest of your code...
}
That's just two possibilities. Being a variable, you can declare a variable of type ObiSolver anywhere in your code and fill it from anywhere you want. As long as you respect C#'s syntax, that is.