EntityRadius question

Blitz3D Forums/Blitz3D Beginners Area/EntityRadius question

Tobo(Posted 2009) [#1]
Dear all,

Just putting together my 3d walk around map type thing, and am having a wee problem with the height of my player: the camera.

I've created my level where the walls etc are effectively 2 units wide.

I have created my ground with a plane and set up collisions with it.

I have also placed a slab on the floor which is also 2 units high. At the moment, as my camera radius is effectively 1, I'm staring at this slab exactly half way up.

When I adjust the radius using EntityRadius cam,1,4 (a tall oval shape, I hope), I still look at the above slab exactly halfway up. I expected to be looking over it.

I'm not very good at explananing thing (especially when I'm in a rush - work awaits), so here's my code.

Graphics3D 800,600,32,2
SetBuffer BackBuffer()

col_player=1
col_ground=2

cam=CreateCamera()
PositionEntity cam,0,8,0
EntityRadius cam,1,4
EntityType cam,col_player

light=CreateLight()

plane=CreatePlane()
EntityColor plane,0,150,0
EntityType plane,col_ground

cube=CreateCube()
PositionEntity cube,1,1,-1

map=LoadMesh("8scale.b3d")
ScaleEntity map,.25,.25,.254


Collisions 1,2,2,2

While Not KeyDown(1)

	If KeyDown(208) Then MoveEntity cam,0,0,-1
	If KeyDown(200) Then MoveEntity cam,0,0,1
	If KeyDown(203) Then TurnEntity cam,0,1,0
	If KeyDown(205) Then TurnEntity cam,0,-1,0

	TranslateEntity cam,0,-.1,0

	UpdateWorld
	RenderWorld
	Flip

Wend
End


In short, how can I make my player taller?


Stevie G(Posted 2009) [#2]
You should really use search as this has been discussed many times. Something like this should work though:

Graphics3D 800,600,32,2
SetBuffer BackBuffer()

col_player=1
col_ground=2

player = CreatePivot()
PositionEntity player,0,8,0
EntityRadius player,1,4
EntityType player,col_player

cam = CreateCamera( player )
PositionEntity cam, 0,4,0

light=CreateLight()

plane=CreatePlane()
EntityColor plane,0,150,0
EntityType plane,col_ground

cube=CreateCube()
PositionEntity cube,1,1,-1

map=LoadMesh("8scale.b3d")
ScaleEntity map,.25,.25,.254

Collisions col_player, col_ground,2,2

While Not KeyDown(1)

	If KeyDown(208) Then MoveEntity player,0,0,-1
	If KeyDown(200) Then MoveEntity player,0,0,1
	If KeyDown(203) Then TurnEntity player,0,1,0
	If KeyDown(205) Then TurnEntity player,0,-1,0

	TranslateEntity player,0,-.1,0

	UpdateWorld
	RenderWorld
	Flip

Wend
End



Tobo(Posted 2009) [#3]
>...You should really use search as this has been discussed many times.

Fair point, and as a rule I do, however, searching 'entityradius' returns a million matches, and 'entityradius height' returns nothing. As I mentioned, I was in a rush this morning.

As we're offering advice on netiquette, I remember my maths teacher never accepting a simple correct answer; they always wanted us to show the working out. With that in mind, would you be so kind as to explain why your version is the 'correct answer', as it were?

Many thanks.


Ross C(Posted 2009) [#4]
He is using a pivot as the collider and the camera as the viewer so to speak. Basically it means the pivot will provide your collisons, but the camera is attached to the pivot (is a child of the pivot), and only gives you a view. You can adjust the camera to any height you wish, without affecting the collisions.


Tobo(Posted 2009) [#5]
Many thanks, Ross.


Tobo(Posted 2009) [#6]
Dear all,

I am incorporating the above advice into my code, which now looks like this...
Graphics3D 800,600,32,2
SetBuffer BackBuffer()

col_player=1
col_ground=2
col_bricks=3

player=CreatePivot()
PositionEntity player,0,8,0
EntityRadius player,1.5,4
EntityType player,col_player

cam=CreateCamera(player)
PositionEntity cam,0,8,0

light=CreateLight()

plane=CreatePlane()
EntityColor plane,0,150,0
EntityType plane,col_ground

cube=CreateCube()
PositionEntity cube,1,1,-1

map=LoadMesh("8scale.b3d")
ScaleEntity map,.25,.25,.25
EntityType map,col_bricks

Collisions col_player,col_ground,2,2
Collisions col_player,col_bricks,2,2

While Not KeyDown(1)

	If KeyDown(208) Then MoveEntity player,0,0,-1
	If KeyDown(200) Then MoveEntity player,0,0,1
	If KeyDown(203) Then TurnEntity player,0,2,0
	If KeyDown(205) Then TurnEntity player,0,-2,0

	TranslateEntity player,0,-.1,0

	UpdateWorld
	RenderWorld
	
	Text 0,0,"Player X:"+EntityX#(player)
	Text 0,15,"Player Y:"+EntityY#(player)
	Text 0,30,"Player Z:"+EntityZ#(player)
	
	Flip

Wend
End


But, it's not stepping over slabs that are on the ground. My Scaleentity map,.25,.25,.25 has made the height of some blocks only 2 units high, but the Player entity (radius 1,4) wont step over them!

Surely anything with a Y radius of 2 or over should step/slide over a 2 unit high block?

The B3D file is here {B3D File} I hope it works.

Any help much appreciated.


Toby


_PJ_(Posted 2009) [#7]
You haven't set EntityType of the cube. If that was needed.

'Stepping Over' things wont happen by default, best way to deal with 'stairs' is to make a ramp with EntityAlpha set to 0.


Tobo(Posted 2009) [#8]
'Stepping Over' things wont happen by default


Surely it does; I've done it before. When you have sphere to polygon collisions, if the centre of the sphere is higher than the polygon it collides with, it will slide over it!

Have I really missed something here?


Stevie G(Posted 2009) [#9]
Something strange is happening here. Your player is sinking into the plane to height 1.5. This matches the X/Z Radius when it should be matching the Y radius of 4?!

On further investigation, it seems like the Y radius does not get used for collisions against a plane, only the X/Z radius. This looks like a bug to me. I've changed the plane to a scaled cube and it all works as expected.

I still use v1.96 so maybe this has been fixed in future versions. I'd be surprised if no-one noticed it before now.

I moved the camera back so that you can see a bit better.

Graphics3D 800,600,32,2
SetBuffer BackBuffer()

col_player=1
col_ground=2
col_bricks=3

player=CreateSphere() ;CreatePivot()
ScaleMesh player, 1.5, 4, 1.5
PositionEntity player,0,20,0
EntityRadius player,1.5,4
EntityType player,col_player

cam=CreateCamera(player)
PositionEntity cam,0,4,-20

light=CreateLight()

;plane=CreatePlane()

plane = CreateCube()
ScaleMesh plane, 1000,1,1000
PositionEntity plane, 0,-1,0
EntityColor plane,0,150,0
EntityType plane,col_ground

cube=CreateCube()
PositionEntity cube,1,1,-1
EntityType cube, col_bricks

;map=LoadMesh("8scale.b3d")
;ScaleEntity map,.25,.25,.25
;EntityType map,col_bricks

Collisions col_player,col_ground,2,2
Collisions col_player,col_bricks,2,2

While Not KeyDown(1)

	If KeyDown(208) Then MoveEntity player,0,0,-1
	If KeyDown(200) Then MoveEntity player,0,0,1
	If KeyDown(203) Then TurnEntity player,0,2,0
	If KeyDown(205) Then TurnEntity player,0,-2,0

	TranslateEntity player,0,-.1,0

	UpdateWorld
	RenderWorld
	
	Text 0,0,"Player X:"+EntityX#(player)
	Text 0,15,"Player Y:"+EntityY#(player)
	Text 0,30,"Player Z:"+EntityZ#(player)
	
	Flip

Wend



Tobo(Posted 2009) [#10]
Thanks, Steve; that was driving me bananas.

Toby


_PJ_(Posted 2009) [#11]
'Stepping Over' things wont happen by default



Surely it does; I've done it before. When you have sphere to polygon collisions, if the centre of the sphere is higher than the polygon it collides with, it will slide over it!


Sorry, I totally misunderstood the issue.

Glad you got it fixed!