But how can I set this ?
I dont know how to access the terrain that is my scene.
Here is the code I have made so far
--require("scripts/hooks")
require("scripts/constants/keycodes")
--Register abstract path
RegisterAbstractPath("")
--Set graphics mode
if Graphics(1024,768,0,60,0)==0 then
Notify("Failed to set graphics mode.",1)
return
end
-- Custom shutDown Variable
ShutDown= false
--Create framewerk object and set it to a global object so other scripts can access it
fw=CreateFramework()
if fw==nil then
Notify("Failed to initialize engine.",1)
return
end
SetGlobalObject("framewerk",fw)
-- Setup Initial Post Processing FX
SetGodRays(1)
SetHDR(0)
SetSSAO(0)
SetBloom(1)
SetAntialias(0)
SetNearDOF(0)
SetFarDOF(1)
SetFarDOFRange(22, 150);
SetZoom(2)
scene=LoadScene("abstract::TestSideScroll.sbx")
camera=fw.main.camera
camera:SetPositionf(0,1.5,-1.5)
-- Create the Player
player2D = CreatePlane();
--player2D:SetPosition(Vec3(0,1.5,2.5))
player2D:SetScale(Vec3(0.5,1,0.7))
player2D:SetRotation(Vec3(270,0,0))
-- Create the Collider for the Player
player2DBody = CreateBodyBox(1,1.5,1)
player2DBody:SetPosition(Vec3(0,1.5,2.5))
-- TestCollider
--playground = CreateBodyBox(5,2,5)
--playground:SetPosition(Vec3(0,0,1))
EntityParent(player2D,player2DBody)
SetBodyMass(player2DBody,0.1)
-- Only for testing
DebugPhysics(1)
-- Enable the Rain Sound Effect
class = classnametable[ "innowork_soundcontroller" ]
if class~=nil then
for model,object in pairs(class.instances) do
object.model:SetKey("enabled","1")
object.model:SetKey("soundfile","Regen.ogg")
end
end
-- Get the RainParticles
myRain = classnametable["environment_emitter"]
if myRain ~=nil then
for model,object in pairs(myRain.instances) do
myRainModel = object.model
end
myRainModel:SetPosition(Vec3(0,6.5,3), 1 )
end
-- Control the Camera (and all object bound to it)
function ControlCamera()
if KeyDown (KEY_D)==1 then
MoveEntity (camera, Vec3(0.1*AppSpeed(),0,0))
-- Move the Rain Particle Effect so that the Rain is allways in the
-- ScreenView
if myRainModel ~=nil then
MoveEntity(myRainModel,Vec3(0.1*AppSpeed(),0,0))
end
-- Move the PlayerSprite
if player2D ~=nil then
MoveEntity(player2DBody,Vec3(0.2*AppSpeed(),0,0))
end
end
if KeyDown (KEY_A)==1 then
MoveEntity (camera, Vec3(-0.1*AppSpeed(),0,0))
-- Move the Rain Particle Effect so that the Rain is allways in the
-- ScreenView
if myRainModel ~=nil then
MoveEntity (myRainModel, Vec3(-0.1*AppSpeed(),0,0))
end
-- Move the PlayerSprite
if player2D ~=nil then
MoveEntity(player2DBody,Vec3(-0.2*AppSpeed(),0,0))
end
end
if KeyDown(KEY_ESCAPE)==1 then
ShutDown=true
end
end
-- Collisions
Collisions(1,1,1);
EntityType(player2DBody,1)
--EntityType(playground,1)
--EntityType(terrain,1)
--
while AppTerminate()==0 and ShutDown == false do
UpdateAppTime()
fw:Update()
fw:Render()
ControlCamera()
Flip(0)
end
Meldrion