collisions/gravity help

Blitz3D Forums/Blitz3D Beginners Area/collisions/gravity help

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I think you can use it as you described:
Graphics3D 800, 600, 0, 2
SetBuffer BackBuffer()

For j = 0 To 256
For i = 0 To 256
	cc = Sin((i-128) * (j-128) / 60) * 64 + 127
	WritePixel i, j, cc Shl 16 + cc Shl 8 + cc
Next
Next
Flip

im = CreateImage(256, 256)
GrabImage im, 0, 0
SaveImage im, "rndterrain.bmp"

terrain = LoadTerrain("rndterrain.bmp")
DeleteFile "rndterrain.bmp"
ScaleEntity terrain, 1, 50, 1
PositionEntity terrain, -128, -50, -128
TerrainShading terrain, 1
EntityType terrain, 2

light = CreateLight()

camera = CreateCamera()
MoveEntity camera, 0, 5, -128

orgsphere = CreateSphere()
EntityColor orgsphere, 255, 0, 0
EntityType orgsphere, 1
HideEntity orgsphere

Collisions 1, 2, 2, 3

Repeat

	If KeyDown(200) Then MoveEntity camera, 0, 0, +1
	If KeyDown(208) Then MoveEntity camera, 0, 0, -1

	If KeyDown(203) Then MoveEntity camera, -1, 0, 0
	If KeyDown(205) Then MoveEntity camera, +1, 0, 0
	
	If fall Then
		If Not(EntityCollided(sphere, 2))
			TranslateEntity sphere, 0, -0.5, 0
		Else
			fall = False
		End If
	Else
		sphere = CopyEntity(orgsphere)
		PositionEntity sphere, Rnd(-128, 128), 0, Rnd(-128, 128)
		ResetEntity sphere
		fall = True	
	End If
	
	UpdateWorld()
	RenderWorld()
	Flip
	
Until KeyHit(1)

End

However, another thing you could try is using a LinePick from the entity down to determine if an object is below it.