Memory access violation on Collisions Command

Blitz3D Forums/Blitz3D Programming/Memory access violation on Collisions Command

GameCoder(Posted 2004) [#1]
When I put the "Collisions" command in I get a MAV. I dont when I take it out. What I'm trying to do is get a collision between the terrain i made in ale and the camera.


Graphics3D 800,600

Global terrain = LoadMesh("terrain\terrain1.b3d")
PositionEntity terrain,0,0,0
EntityType terrain,1,False

AmbientLight 255,255,255

Global camera = CreateCamera()
PositionEntity camera,0,100,0
EntityType camera,1,False
EntityRadius camera,1

MoveMouse 400,300

Collisions camera,terrain,1,2

While Not KeyHit(1)
	
	RotateEntity camera,MouseY(),-MouseX(),0
	
	movecamera()
	
	UpdateWorld
	RenderWorld()
	Flip
	
Wend
End

Function movecamera()
	
	If KeyDown(200)
		
		MoveEntity camera,0,0,0.2
	
	ElseIf KeyDown(208)
	
		MoveEntity camera,0,0,-0.2
	
	EndIf
	
	If KeyDown(203)
		
		MoveEntity camera,-0.2,0,0
			
	ElseIf KeyDown(205)
	
		MoveEntity camera,0.2,0,0
			
	EndIf
	
	
End Function



DJWoodgate(Posted 2004) [#2]
You have to use collisions in conjunction with the EntityType command.


GameCoder(Posted 2004) [#3]
Well I have assigned wntity types to both the terrain and the camnera. Which bit Have a made a mistake in?


DJWoodgate(Posted 2004) [#4]
You specify that type number as an argument to the Collisions command, not the entity handle. So perhaps you should give the terrain a different type number from the camera.


jfk EO-11110(Posted 2004) [#5]
that's true

entitytype camera,1
entitytype terrain,2

collisions 1,2,2,2

would work better.


GameCoder(Posted 2004) [#6]
Ok lets see if I understand this.

If I set the camera up as "entitytype camera,1" and the terrain as "entitytype terrain,2" the first parts of "Collisions" is this then, Collision 1,2. The 1,2 bit is the actual entitie's. Yes/NO. The the second part is the mothod type then the respone they do to eachother.

So Collisions 1,2,2,2 is a collision between the camera and the terrain, sphere to poly, slide.

Yes O_o

So If I had other entities and wanted to do the same, I would give the entity type a 3 then 4 and so on and the collision between 3 and 4 would be Collisions 3,4,2,2

Am I making sense because I have confused myself here.

Thx for the help anyways. It works now ;)


Sledge(Posted 2004) [#7]

So If I had other entities and wanted to do the same, I would give the entity type a 3 then 4 and so on and the collision between 3 and 4 would be Collisions 3,4,2,2



Yes, or you could stack, say, all your scenery elements up as of the same type if, for instance, you constructed a single level out of mutiple maplet geometries.


DrakeX(Posted 2004) [#8]
and to make it simpler to understand, you would generally do this:

Const COLTYPE_PLAYER=1
Const COLTYPE_ENEMY=2
Const COLTYPE_GROUND=3

EntityType player,COLTYPE_PLAYER
EntityType land,COLTYPE_GROUND

For en.enemy=Each enemy
EntityType en\entity,COLTYPE_ENEMY
Next

Collisions COLTYPE_PLAYER,COLTYPE_GROUND,x,y
Collisions COLTYPE_PLAYER,COLTYPE_ENEMY,blah,blah

and so on. each type number represents a class of entities - such as enemies or players. you don't assign a new type number to each entity :P that would be a pain in the ass and a total defeat of the collision system.