Hello, I have spent many hours scouring the net to get cryenging ready for my own code. I am compiling what I know from what I have found to help save YOU (Thats' right, YOU, you intelligent, beautiful/handsome and witty reader) so many frustrating hours I have endured. Without further adieu, lets begin:
When first loading CryEngine with MicrosoftVisual Studio 2010 it will not be able to open up
the solution file for CryEngine, the files grayed out I just deleted. After
it is deleted I added the CryCommon file, and it works fine.
Compiling for the fist time I got an error with "cannot open afxres.h". Replacing it with "windows.h" fixes this.
Here's why: THIS is an MFC.
MFC stands for "Microsoft Foundation Class Library".
MFC is an OOP wrapper for windows API.
windows.h is a header file for C language which is not OOP.
windows.h contains declarations for ALL of the windows API.
It's just one of MANYannoying work arounds I came across in my CryEngine Adventures
T stands for sTupendous success!!! This is a 3D model and a 2D image on a lua script marking
out on the map where the entity is placed. Its a teleporter script and the code is below:
TWO important things on lua scripts in Cry:
1)The first block of LUA code is a .ent definition which is the name of this entity
and defines the scripts location.
(These lau scripts are not my own. Remember: It's a compilation of what I found to get started)
<Entity
Name="Teleporter"
Script="Scripts/Entities/Others/Teleporter.lua"
/>
(You may notice this is written as .xml and that's because I don't know... It's cryengine)
2)the actual .lua script is where the constructor and functions are.
Teleporter = {
Editor =
{
Icon= "AreaTrigger.bmp",
},
Properties =
{
teleportDirX = 0,
teleportDirY = 0,
teleportDirZ = 0,
object_3DModel = "Editor/Objects/T.cgf",
},
}
function Teleporter:OnInit()
self:OnReset();
end
----------------------------------------
function Teleporter:OnPropertyChange()
self:OnReset();
end
----------------------------------------
function Teleporter:OnReset()
--this will set the selected 3D Model on the entity
if (self.Properties.object_MyModel ~= "") then
self:LoadObject(0, self.Properties.object_3DModel);
end
end
--tell the engine that we can interact with this entity
function Teleporter:IsUsable(user)
return 1;
end
----------------------------------------
function Teleporter:OnUsed(user)
--check „user" being valid
if (not user) then
return 0;
end
--compute target position from current position + teleport
direction()
local vCurPos = {};
user:GetWorldPos(vCurPos);
local vTargetDir = {}; --assign a temp vector as targetDir „type"
vTargetDir.x = self.Properties.teleportDirX;
vTargetDir.y = self.Properties.teleportDirY;
vTargetDir.z = self.Properties.teleportDirZ;
local vTargetPos = vecAdd(vCurPos, vTargetDir);
--set target position on player entity
user:SetWorldPos(vTargetPos);
end
This picture just shows the properties that are written in the .lua script above.
This is a cpp script that will be called on another .lua teleporter script. It functions essentially the same,
but it's just showing how lua can call on a .cpp function.
This block of code also checks to make sure that the pointer is NOT NULL. Without this exception handler
the game will crash.
This is a script bind function. ALL BIND FUNCTIONS HAVE:
1)Always returns a script
2)ALWAYS gets an 'IFunctionalHandler *pH'
as the first argument.
This registers all that happy fun stuff I did earlier. All these start the same as you can see.
============================================================================================================================================================================================================
Here below I have succesfully utilized the 3rd Person Camera in CryEngine. This can be done in the flowgraph, but I chose to do it in C++. The code is going to be located here: GameRules.cpp, line 829 you should see this: bool CGameRules::OnClientEnteredGame(int channelId, bool isReset)
//so then add this right below
//Gives 3rd Person View
ICVar* pTmpVar = gEnv->pConsole->GetCVar("g_tpview_control");
pTmpVar->ForceSet("1");
pTmpVar = gEnv->pConsole->GetCVar("g_tpview_enable");
pTmpVar->ForceSet("1");
pTmpVar = gEnv->pConsole->GetCVar("g_tpview_force_goc");
pTmpVar->ForceSet("0");
//=======================
I hope this compilation of obscure tutorials will help you get started as it has helped me. I tried to put all the 'work arounds' to getting the code up and running in one easy place.






