simple easy collision (you need sparky's to use it) by Pwnage30th Apr 2007 16:58
|
---|
Summary This is a very simple collision by sparky's (I added a few touches myself) it works well for dbo worlds and any other type of world. Description Hopefully it is easy enough for begginers to understand (i'm a begginer myself). remember you need to position the your player object above the world or else the collision won't work. Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com rem make the player object make object sphere your player object I used a sphere,20 Sc_setupobject 16,0,2 rem setup your world load object "your world.dbo",world num Sc_setupcomplexobject world num,1,2 rem collision for the person oldx# = object position x(your object) oldy# = object position y(your object) oldz# = object position z(your object) rem move the player if keystate(17)=1 then move object your object,3 if keystate(31)=1 then move object your object,-3 if keystate(30)=1 then move object left your object,3 if keystate(32)=1 then move object right your object,3 rem if player isn't pressing a key apply simple gravity if keystate(17)=0 then position object your object, object position x(your object),object position y(your object)-0.4, object position z(your object) if keystate(31)=0 then position object your object, object position x(your object),object position y(your object)-0.4, object position z(your object) if keystate(30)=0 then position object your object, object position x(your object),object position y(your object)-0.4, object position z(your object) if keystate(32)=0 then position object your object, object position x(your object),object position y(your object)-0.4, object position z(your object) x# = object position x(your object) y# = object position y(your object) z# = object position z(your object) collide = sc_SphereSlideGroup(1,oldx#,oldy#,oldz#,x#,y#,z#,100,0) if collide>0 x# = sc_getCollisionSlideX() y# = sc_getCollisionSlideY() z# = sc_getCollisionSlideZ() position object your player object,x#,y#,z# endif rem position the camera position camera object position x(yourobject),object position y(your object),object position z(your object) rem camera control/player movement rotate camera camera angle x(0)+(mousemovey()/2.0),camera angle y(0)+(mousemovex()/2.0),0 cx#=camera angle x(0) : cy#=camera angle y(0) if wrapvalue(camera angle x(0))>40 and wrapvalue(camera angle x(0))<180 then xrotate camera 0,40 if wrapvalue(camera angle x(0))>180 and wrapvalue(camera angle x(0))<280 then xrotate camera 0,280 |