Hi Everyone,
I am having some trouble adding jumping and gravity to the game i am making. I am using RUCCUS's sliding collision script(with sparky's dll), I have a cube and a map (.x)
Collisions work okay but i need gravity and jumping. I have tried some ideas given on other posts but none of them seem to work with what I have.
I have attached the map and here what i have so far:
SYNC ON
SYNC RATE 0
AUTOCAM OFF
Make Matrix 1,500,500,20,20
MAKE OBJECT cube 1,3
Position Object 1,470,5,0
Camdist# = 15.0
TrackAngle = 0
ReqCamHeight# = 1.0
Camsmooth = 200
ColFlag = 0
load OBJECT "terrain_1/terrain.x", 2
SC_SetupObject 2,0,0
Do
If LeftKey()=1 Then Y# = WrapValue(Object Angle Y(1)-.3): Yrotate Object 1,Y#
If RightKey()=1 Then Y# = WrapValue(Object Angle Y(1)+.3): Yrotate Object 1,Y#
ObjX# = Object Position X(1): ObjZ# = Object Position Z(1)
ObjHeight# = object position y(1)
Set Camera To Follow ObjX#,ObjHeight#,ObjZ#,WrapValue(Object Angle Y(1)+TrackAngle),Camdist#,15,Camsmooth,ColFlag
ox# = Object position x(1)
oy# = object position y(1)
oz# = object position z(1)
MOVE OBJECT 1,( UPKEY()-DOWNKEY() ) * .3
x# = object position x (1)
y# = object position y (1)
z# = object position z (1)
slidingcollision(ox#,oy#,oz#,x#,y#,z#,10,1,2)
SYNC
LOOP
FUNCTION SlidingCollision(X1#,Y1#,Z1#,X2#,Y2#,Z2#,Radius#,Dyn,Obj)
C = sc_SphereSlide(Obj,X1#,Y1#,Z1#,X2#,Y2#,Z2#,Radius#,0)
IF C > 0
cx# = sc_getCollisionSlideX()
cy# = sc_getCollisionSlideY()
cz# = sc_getCollisionSlideZ()
POSITION OBJECT Dyn, cx#, cy#, cz#
ENDIF
ENDFUNCTION
DELETE MEMBLOCK 1
If someone has any ideas on a way to add jumping and/or gravity that would be a big help.
Also, I had to make the cube quite small because when i try to make the map larger using the scale object command, collisions stop working. Any ideas on that would be much appreciated.