for a while I have started to make simple games with Unity and learned basic C# with the Engine. For a couple of days I have heard that also now CryEngine is supporting C# and I thought, lets give it a try. What I want to say is I haven't that much experiences with programming (and only in C# :P), a bit knowledge about Game Development in general and I am completely new to CryEngine. So please be patient if I am not getting the most obviously things immediately.
My first title was "How I can Invoke a Method in C# from the Console".
My starting Point was:
The first parameter is the the name of the Command, okay!
but what is the second parameter "_CrySystem_cs_SWIGTYPE_p_f_p_IConsoleCmdArgs__void" ? I need something like a callback or not? Passing in a delegate or something? So I can type the command name and then the delegate gets Invoke or so?
After I can't find any solution for this problem, I have looked for a work arround.
Then I have found CVar, Console Variables. My Idea was, I can create a Variable and in the Update Method I can check if the Variable is getting a specific Value and then I call a Method.
I have implemented the following way:
Code: Select all
bool onlyOne = false;
void FixedUpdate (float deltaTime)
if (!GameManagement.gameRunning) return;
if (onlyOne == false)
onlyOne = true;
myCVar = Engine.Console.RegisterInt("MyCVar", 0, 0);
if (myCVar == null) return;
For a better understanding the GameManagement class I have written by myself so I can easier create classes with OnGameStart and Update and FixedUpdate Methods (but this I working well).
"MyCVar" is registered, because when I remove the onlyOne if statement I get the error that "MyCVar" is already registered. And when I run this code its logging 0 all the time. (So far so good)
But how I can change this Variable in the Console in the Sandbox. When I write in the Console:
I get "Unknown Command"
and thats why "MyCVar = 1" or something like that also didn't work.
So how I can change this CVar in the Console?
Or is my code already wrong?
Must I use "Engine.Console.GetCVar("MyCVar");" instead of saving the ICVar in a variable in C#?
Thanks for any help!