Trouble with Tokamak (probably easy to fix)

Blitz3D Forums/Blitz3D Programming/Trouble with Tokamak (probably easy to fix)

Guess what? I'm getting a memory access violation. Help please. Do I always need to use render tweening with tokamak physics? Or is it just there in all the examples because it's better? Here's my code, it's a bit butchered because of my panic but it should work. You may as well just change Global ship01=LoadMesh("ship1.b3d") to Global ship01=createCube() to make it able to work when / if it does.

;3d space flight engine v 3
;now that I have proper physics, I think it may work out
;I'm aiming to fix the gameplay problem involving it just not 'feeling' right

;set up graphics
Graphics3D 1024,768,32

;double buffering
SetBuffer BackBuffer()

;set up tokamak simulator

TOKSIM_SetRigidBodiesCount 1
TOKSIM_SetAnimatedBodiesCount 0
TOKSIM_SetRigidParticleCount 0
TOKSIM_SetControllersCount 0
TOKSIM_SetGeometriesCount 14

TOKSIM_CreateSimulator(0,0,0)

;load the ship
;NOTE: CHANGE THIS TO AN ARRAY!!
Global ship01=LoadMesh("ship1.b3d")

;the camera
Global cam1 = CreateCamera()
PositionEntity camera,0,0,0

;the lights
AmbientLight 100,100,200

;the ship rigid body
ship01rb=TOKRB_Create()
	TOKRB_SetPosition ship01rb,0.0,0.0,0.0
	TOKRB_SetRotation ship01rb,0.0,0.0,0.0
	TOKRB_SetBoxInertiaTensor ship01rb,5.0,5.0,5.0,1.0
	TOKRB_SetMass ship01rb,1.0
	TOKRB_SetLinearDamping ship01rb,0.001
	TOKRB_SetAngularDamping ship01rb,0.001
	TOKRB_CollideConnected ship01rb,0

	TOKRB_AddBox(ship01rb,-2.20411,-2.88501,2.09501)
		TOKGEOM_SetPositionAndRotation g,-3.78355,-0.312894,-0.471711,0.0,0.0,0.0

	TOKRB_AddBox(ship01rb,2.0,-0.913641,-1.19867)
		TOKGEOM_SetPositionAndRotation g,-3.78568,-2.07925,-0.294399,0.0,0.0,0.0

	TOKRB_AddBox(ship01rb,-2.0,-3.0,0.804565)
		TOKGEOM_SetPositionAndRotation g,-3.85608,-3.90423,-0.268204,0.0,0.0,0.0

	TOKRB_AddBox(ship01rb,1.86821,-0.93018,-0.757756)
		TOKGEOM_SetPositionAndRotation g,-3.94073,-5.83604,-0.289075,0.0,0.0,0.0

	TOKRB_AddBox(ship01rb,1.44042,-0.808995,-0.571616)
		TOKGEOM_SetPositionAndRotation g,-3.83165,-6.66908,-0.3939,0.0,0.0,0.0

	TOKRB_AddBox(ship01rb,-1.36885,-1.11293,-0.847562)
		TOKGEOM_SetPositionAndRotation g,-2.3013,-0.285581,-0.419939,0.0,0.0,0.0

	TOKRB_AddBox(ship01rb,1.5764,-0.906782,-0.5684)
		TOKGEOM_SetPositionAndRotation g,-0.947437,-0.327261,-0.415343,0.0,0.0,0.0

	TOKRB_AddBox(ship01rb,1.49912,-1.17104,-0.826421)
		TOKGEOM_SetPositionAndRotation g,-5.59488,-0.325605,-0.399286,0.0,0.0,0.0

	TOKRB_AddBox(ship01rb,1.20174,-0.92761,0.578545)
		TOKGEOM_SetPositionAndRotation g,-6.92694,-0.300521,-0.372304,0.0,0.0,0.0
		
	TOKRB_AddBox(ship01rb,0.379707,-2.13287,1.27555)
		TOKGEOM_SetPositionAndRotation g,-0.0445214,-0.347584,-0.413206,0.0,0.0,0.0
		
	TOKRB_AddBox(ship01rb,-0.320397,-2.21165,-1.36992)
		TOKGEOM_SetPositionAndRotation g,-7.58982,-0.350264,-0.375476,0.0,0.0,0.0

	TOKRB_AddBox(ship01rb,0.246424,-1.22218,0.220696)
		TOKGEOM_SetPositionAndRotation g,-0.0723057,-1.96473,-0.402167,0.0,0.0,0.0

	TOKRB_AddBox(ship01rb,-0.237158,-1.5,0.245809)
		TOKGEOM_SetPositionAndRotation g,-7.61479,-1.83985,-0.40037,0.0,0.0,0.0

	TOKRB_AddCylinder(ship01rb,1.73311,2.2236)
		TOKGEOM_SetPositionAndRotation g,-3.80075,-4.39053,-0.900166,0.0,0.0,0.0

;main loop
While Not KeyDown(1)

	TOKRB_UpdateBoundingInfo ship01rb

	;match ship01 to the tokamak rigid body
		PositionEntity ship01,TOKRB_GetX#(ship01rb),TOKRB_GetY#(ship01rb),TOKRB_GetZ#(ship01rb)
		RotateEntity ship01,TOKRB_GetPitch#(ship01rb),TOKRB_GetYaw#(ship01rb),TOKRB_GetRoll#(ship01rb),False

	;update the simulator
		TOKSIM_Advance(1,1)
		
	;more double buffering
		Flip
		

	UpdateWorld
	RenderWorld
	
Wend

TOKSIM_DestroySimulator()
End


I am using the tokamak rigid body editor and when I create the rigid body object it is the same as what I get when I export .bb except without the setmaterialindex command because I removed or changed most of the variable names and was too lazy to deal with it. All I am trying to do for now is draw the ship onscreen with the tokamak rigid body working if you're wondering. I don't thuink I finished setting up the camera either, so if you get nothing but no memory access violation that's good, you don't need to set it up.

Thanks in advance

No need to reply. Apparently I referred to my camera as "camera" when it was called "cam1". I thought that gave me a different error than illegal memory address though...

It will if you're in debug.

oh, woops, thanks.