So I'm working on a project with someone and I begun the engine today, except for one small problem, collision, here's my very basic code, can't post the media cus it's too big:
Rem Project: Olympia Apoyalypse
Rem Created: 2/20/2005 4:51:29 PM
Rem ***** Main Source File *****
Sync On
Sync Rate 120
Backdrop on
Color Backdrop RGB(200,200,200)
Autocam off
hide mouse
`Load Images
Load image "hud1.png",1
`Font Settings
Set Text Font "Arcade N"
Set Text Size 8
global dim object(500,2)
gosub _collision_setup
`Variables
Health= 500
Enemy= 500
`Make Hero
Make object cube 1,10
Color Object 1,RGB(0,0,200)
Yrotate object 1,90
CollisionTypePRO( 1, TYPE_PLAYER )
PositionObjectPro(1,0,100,40)
SetObjGravityPRO( 1, 2 )
SetObjRadiusPRO( 1, 5,5,5)
`SetEllipOffsetPRO( 1, 0, -4, 0 )
ResetObjPRO(1)
`Make Enemy
Make object cube 2,10
Color Object 2,RGB(200,0,0)
Yrotate object 2,-90
CollisionTypePRO( 2, TYPE_OBJECT )
PositionObjectPro(2,80,100,40)
SetObjGravityPRO( 2, 2 )
SetObjRadiusPRO( 2, 5,5,5)
`SetEllipOffsetPRO( 2, 0, -4, 0 )
ResetObjPRO(2)
`Arena
Load object "arena.x",3
yrotate object 3,90
CollisionTypePRO(3, TYPE_WORLD)
PositionObjectPro(3,0,-70,150)
ScaleObjectPro(3,50,50,50)
object(3,1)=0
object(3,2)=0
Do
`Huds
Sprite 1,5,5,1
Ink RGB(0,0,100),0
Text 20,60,"Player 1"
Sprite 2,360,5,1
Position object 1,Object position X(1),Object position Y(1),Object position Z(1)
Position camera Object position X(1)+20,Object position Y(1),Object position Z(1)-80
`Controls
Gosub Collision
RunCollisionPRO()
If rightkey()=1
moveobjectPRO(1,1)
endif
If leftkey()=1
moveobjectPRO(1,-1)
endif
Sync
Loop
_collision_setup:
#include "NGCollision.dba"
`SOME globals to make (SetCollisions) and ray-cast
`statements easier to read. Used for collision.
#Constant NCULL_COUNTER_CLOCK 1
#Constant NCULL_CLOCK 2
#Constant NCULL_NONE 3
#Constant TYPE_NGC_ELLIP=1
#Constant TYPE_NGC_MESH=2
#Constant ELLIP_2_ELLIP=1
#Constant ELLIP_2_POLY=2
#Constant RESP_STICK=1
#Constant RESP_SLIDE=2
#Constant RESP_SLIDE_NO_SLOPES=3
#Constant RESP_SLIDE_NO_GRAV=4
#Constant RESP_SLIDE_NO_ACCEL=5
#Constant RESP_NONE=6
#Constant DYN_NO_RESP=1
#Constant DYN_RESP=2
#Constant DYN_RESP_NOTURN=3
`End globals
`This starts the collsiion system and must be called first.
StartCollisionPRO(xxx,xxx,xxx)
`put the collision system into debug while developing.
StartCollisionDebugPRO()
`keep
SetCollisionExclusive( 1 )
`Make a constant for each object
#Constant TYPE_PLAYER = 1
#Constant TYPE_FOLLOW_CAM = 2
#Constant TYPE_WORLD = 3
#Constant TYPE_OBJ = 4
SetCollisionsPro( TYPE_PLAYER, TYPE_OBJ, ELLIP_2_EllIP, RESP_SLIDE, DYN_RESP, 0 )
SetCollisionsPro( TYPE_PLAYER, TYPE_WORLD, ELLIP_2_POLY, RESP_SLIDE, DYN_RESP, 0 )
SetCollisionsPro( TYPE_SENSOR, TYPE_WORLD, ELLIP_2_POLY, RESP_STICK, DYN_RESP, 0 )
SetCollisionsPro( TYPE_OBJ, TYPE_WORLD, ELLIP_2_POLY, RESP_SLIDE, DYN_RESP, 0 )
`Use bigger elipsoid for collision (recoomended)
`SetEllipSizeModePRO(1)
SetOctreeBuild( 0 )
return
collision:
`first check for any collision going on
if CountCollisionsPRO(1)>0
`then check for what objects are colliding
for col=1 to CountCollisionsPRO(1)
`get the object number that is colliding
obj=CollisionHitObj(1,col)
`get what type it is and the extra number
coltype=object(obj,1)
colextra=object(obj,2)
`then perform what should happen based on type
`coltype=1 then do nothing because it is a solid object
`wipe old data
coltype=0
colextra=0
obj=0
next col
endif
return
First off only the player character falls to the arena, I think this is because the enemy hits the top of a pillar. But the problem is when I start it up I get a collision error, this is it word for word:
Quote: "invalid object number sent"
That's all. I have no clue what's the causing the problem or anything also the collision don't work great if I move towards the right hand side of the level befor e I reach the edge I suddenly drop...
Anyone know what the problem is?
Also sorry if this is the wrong board.