Hello. I followed the instructions to set up the physics for all the objects in my level. Gravity is working automatically, but I don't know how to activate the collision.
Function MainLoop()
`Create Characters
Parse_File("World\Heroes\PCharacter.txt",1)
REM Create Luka. Scale, position, and add collision.
tempObj = FreeObject()
Luka = CreateCharacter( tempObj, PFile(0,0), Val(PFile(0,1)), Val(PFile(0,2)), Val(PFile(0,3)), Val(PFile(0,4)), Val(PFile(0,5)), Val(PFile(0,6)), Val(PFile(0,7)), Val(PFile(0,8)), Val(PFile(0,9)), Val(PFile(0,10)), Val(PFile(0,11)),PFile(0,12))
load object PFile(1,0),_Char(Luka).Object
phy make box character controller _Char(Luka).Object,375,331,424,75,75,75,1,2.0,45
`Load Map
Parse_File("World\Levels.txt",3)
REM Create Land1. Scale and position the object. Add Sparky Collision
tempObj = FreeObject()
tempObj2 = FreeObject()
Land = CreateLevel(PFile(0,0),tempObj, Val(PFile(0,2)), Val(PFile(0,3)), tempObj2)
load object PFile(0,1),_Map(Land).LvFile
load object PFile(0,4),_Map(Land).Sky
POSITION OBJECT _Map(Land).LvFile,-400,300,0
phy make rigid body static mesh _Map(Land).LvFile
`sc_setupComplexObject _Map(Land).LvFile,1,2
`Make Skybox for Land1
set object light _Map(Land).Sky,0
scale object _Map(Land).Sky,10000,10000,10000
set object texture _Map(Land).Sky,2,1
set object cull _Map(Land).Sky,0
phy make rigid body static convex _Map(Land).Sky
OceanMDL = FreeObject()
`Make Water
MakeWater(OceanMDL)
position camera 375, 350, 300
Do
PlayerMove(_Char(Luka).Object)
`Update Water
UpDateWater(OceanMDL,350.0)
phy update
sync
Loop
Function PlayerMove(model)
REM If player is moving, animate it
if player_state=0 then loop object model, 173,173
if player_state=1 then loop object model,1,150
rem Move player (eight-directional movement)
If Downkey()=1 AND Leftkey()=1
yrotate object model,45
`yrotate object model,curveangle(45,object angle y(model),10)
phy move character controller model, 200.0
player_state=1
else
If Downkey()=1 AND Rightkey()=1
yrotate object model,-45
`yrotate object model,curveangle(-45,object angle y(model),10)
phy move character controller model, 200.0
player_state=1
else
If Upkey()=1 AND Leftkey()=1
yrotate object model,135
`yrotate object model,curveangle(135,object angle y(model),10)
phy move character controller model, 200.0
player_state=1
else
If Upkey()=1 AND Rightkey()=1
yrotate object model,-135
`yrotate object model,curveangle(-135,object angle y(model),10)
phy move character controller model, 200.0
player_state=1
else
If Upkey()=1
yrotate object model,180
`yrotate object model,curveangle(180,object angle y(model),10)
phy move character controller model, 200.0
player_state=1
else
If Downkey()=1
yrotate object model,360
`yrotate object model,curveangle(360,object angle y(model),10)
phy move character controller model, 200.0
player_state=1
else
If Leftkey()=1
yrotate object model,90
`yrotate object model,curveangle(90,object angle y(model),10)
phy move character controller model, 200.0
player_state=1
else
If Rightkey()=1
yrotate object model,270
`yrotate object model,curveangle(270,object angle y(model),10)
phy move character controller model, 200.0
player_state=1
else
player_state=0 : phy move character controller model, 0.0
endif : endif : endif: endif : endif : endif : endif : endif
phy set character controller displacement model, 0.0, 0.0
print "player state = ",player_state
rem END directional movement----------------------------------------------------
Endfunction
I used
phy make box character controller just like in the tutorial to set up my character, and I used
phy make rigid body static mesh for my DBO level, which is a terrain made in 3DWS.
Is there a reason why the collision works in the Character Controller tutorial and not my program?
I included the project, but it might not run if you aren't using CodeSurge.
Currently working on - Enemy AI and Action Battle System
the sig limit needs to be raised...