level collision. One surface, how to make it solid

Blitz3D Forums/Blitz3D Beginners Area/level collision. One surface, how to make it solid

GameCoder(Posted 2004) [#1]
Ok my level is lame. How should I go about making it solid. ie entities cant go through wall or the floor?

Noob at B3D spam post = 1 ;)


puki(Posted 2004) [#2]
"Amon" are you being serious - or is this another of your wind-ups?


GameCoder(Posted 2004) [#3]
ROFL

I'm afraid I'm being serious. Is the question I asked really that stupid?

I dont understand 3d like I do 2d. I have been reading the tuts and on sphere collision between entities. But its not sphere collisions that I want is it? The whole level has to be collidable.


GameCoder(Posted 2004) [#4]
^^


GameCoder(Posted 2004) [#5]
:D


puki(Posted 2004) [#6]
If the level is all one mesh then just give it an 'EntityType' let's say 'EntityType level(or whatever you called it),2' - set up the player with 'EntityType player,1' - set collisions with 'Collisions 1,2,2,3'

The following is slightly different as I create the level on-the-fly - but you should be able to pick the bones of it:

; mini-mini Sausage Dweller - puki - 2004

Graphics3D 800,600; change this to whatever you want
HidePointer

walkspeed#=.1; speed at which the camera/player moves at - originally set to .1 (just in case you changed it)
no_of_data=11; number of lines of data in mapdata

SeedRnd MilliSecs(); this is vital for random numbers (helps the bot choose more randomly)

;create the ground
floor1=CreatePlane()
EntityColor floor1,50,255,50
PositionEntity floor1,0,-2.3,0 
EntityType floor1,2

;create camera/player
Global player=CreatePivot()
Global camera=CreateCamera(player)
CameraRange camera,1,100
CameraClsColor camera,50,50,200; colour the sky
PositionEntity player,5,1,-20
EntityType player,1

wallheight#=2.5
;create wall block
block=CreateCube()
ScaleEntity block,2.5,wallheight,2.5
EntityColor block,100,100,100
EntityAlpha block,.3
EntityType block,2
HideEntity block


.mapdata
Data "01000000000"
Data "03111311130"
Data "01000100010"
Data "01000100010"
Data "01000100010"
Data "03111313130"
Data "01000101010"
Data "01000313130"
Data "01000101010"
Data "03111313130"
Data "00000000000"

;draw the 2D maze data into a 3D world
Restore mapdata; find the block of data
number_of_blocks=0
wpc=0
For c=0 To no_of_data-1
Read m$
For a=1 To 11; loop through the data

	;draw the wall blocks
	If Mid$(m$,a,1)="0"
		newblock=CopyEntity(block); make a copy of the original entity
		PositionEntity newblock,xx,0.2,zz
		number_of_blocks=number_of_blocks+1; not necessary - just counts total number of blocks
	End If

;NOTE "1"'s are ignored, the are empty spaces - the values I have chosen are irrelevent

;this code block is used to space out the 'wall blocks'
x=x+1; a simple counter
xx=xx+5; increment the spacing
If x=11; maximum number of items (numbers 0-9) in data statment
	x=0; make it=0 as we are at the end of a line of data
	zz=zz+5; increment the spacing
	xx=0; move the location of the next 'wall block' back to position 0
EndIf

Next 
Next


Collisions 1,2,2,3; stops you walking though the walls


; MAIN LOOP ***************************************************
While Not KeyHit(1)

pz=EntityZ(player)
px=EntityX(player)

Gosub MoveCamera

UpdateWorld
RenderWorld
Flip
Wend
End
;---------------------------------------------------------------

; I could have used functions - but gosubs will suffice (no need to use 'Global' variables)
.MoveCamera
mx#=-.25*MouseXSpeed()
my#=.25*MouseYSpeed()
MoveMouse GraphicsWidth()/2,GraphicsHeight()/2

TurnEntity player,0,mx#,0,1
TurnEntity camera,my#,0,0,0

If KeyDown(200) Or KeyDown(17) Then MoveEntity player,0,0,walkspeed
If KeyDown(208) Or KeyDown(31) Then MoveEntity player,0,0,-walkspeed
If KeyDown(205) Or KeyDown(32) Then MoveEntity player,walkspeed,0,0
If KeyDown(203) Or KeyDown(30) Then MoveEntity player,-walkspeed,0,0
Return



GameCoder(Posted 2004) [#7]
a thousand thankyous

:)


puki(Posted 2004) [#8]
Hope it helps - you really need someone like "Ross C" or similar to explain this sort of stuff - I don't really understand Blitz3D - I just sort of do it.


GameCoder(Posted 2004) [#9]
I don't really understand Blitz3D - I just sort of do it.


Thats interesting. I'd kinda like to be like that also because I spend forever trying to understand why things work while giving no time to actually doing things in the language.

Thx Puki :)


jhocking(Posted 2004) [#10]
Use the Collisions command to setup Sphere-to-Polygon collision detection between the player and level.


Neo Genesis10(Posted 2004) [#11]
When I first started with collisions, the first mistake I made was to use an entity type of zero, which caused all sorts of headaches. I'd still like to see a Null collision type where it records only...