Home
Products
Community
Manuals
Contact
Login or Signup

Blitz3D Docs -> 3D - A-Z -> E -> EntityRadius

EntityRadius entity,x_radius#[,y_radius#]

Parameters:

entity - entity handle
x_radius# - x radius of entity's collision ellipsoid
y_radius# (optional) - y radius of entity's collision ellipsoid. If omitted the x_radius# will be used for the y_radius#.

Description:

Sets the radius of an entity's collision ellipsoid.

An entity radius should be set for all entities involved in ellipsoidal collisions, which is all source entities (as collisions are always ellipsoid-to-something), and whatever destination entities are involved in ellipsoid-to-ellipsoid collisions (collision method No.1).

See also: EntityBox, Collisions, EntityType.

Example:

; EntityRadius Example
; --------------------

Graphics3D 640,480
SetBuffer BackBuffer()

camera=CreateCamera()
light=CreateLight()

sphere=CreateSphere( 32 )
PositionEntity sphere,-2,0,5

cone=CreateCone( 32 )
EntityType cone,type_cone
PositionEntity cone,2,0,5

; Set collision type values
type_sphere=1
type_cone=2

; Set sphere radius value
sphere_radius#=1

; Set sphere and cone entity types
EntityType sphere,type_sphere
EntityType cone,type_cone

; Enable collisions between type_sphere and type_cone, with ellipsoid->polygon method and slide response
Collisions type_sphere,type_cone,2,2

While Not KeyDown( 1 )

x#=0
y#=0
z#=0

If KeyDown( 203 )=True Then x#=-0.1
If KeyDown( 205 )=True Then x#=0.1
If KeyDown( 208 )=True Then y#=-0.1
If KeyDown( 200 )=True Then y#=0.1
If KeyDown( 44 )=True Then z#=-0.1
If KeyDown( 30 )=True Then z#=0.1

MoveEntity sphere,x#,y#,z#

; If square brackets keys pressed then change sphere radius value
If KeyDown( 26 )=True Then sphere_radius#=sphere_radius#-0.1
If KeyDown( 27 )=True Then sphere_radius#=sphere_radius#+0.1

; Set entity radius of sphere
EntityRadius sphere,sphere_radius#

; Perform collision checking
UpdateWorld

RenderWorld

Text 0,0,"Use cursor/A/Z keys to move sphere"
Text 0,20,"Press [ or ] to change EntityRadius radius_x# value"
Text 0,40,"EntityRadius sphere,"+sphere_radius

Flip

Wend

End

Comments

eBusiness(Posted 1+ years ago)
The y_radius still doesn't work, if it is anything but the x_radius, it will create a mathematical bug.


simonh(Posted 1+ years ago)
Specifying a y_radius works fine here:
; EntityRadius Example 
; -------------------- 

Graphics3D 640,480 
SetBuffer BackBuffer() 

camera=CreateCamera() 
light=CreateLight() 

cone=CreateCone( 32 ) 
EntityType cone,type_cone 
PositionEntity cone,2,0,5 

ellipsoid=CreateSphere( 32 ) 
PositionEntity ellipsoid,-2,0,5 

; Set radius values 
xradius#=1 
yradius#=1.5

; Set ellipsoid scale and entity radius to same as radius values
ScaleEntity ellipsoid,xradius#,yradius#,1.0
EntityRadius ellipsoid,xradius#,yradius#

; Set collision type values 
type_ellipsoid=1 
type_cone=2 

; Set ellipsoid and cone entity types 
EntityType ellipsoid,type_ellipsoid 
EntityType cone,type_cone 

; Enable collisions between type_ellipsoid and type_cone, with ellipsoid->polygon method and slide response 
Collisions type_ellipsoid,type_cone,2,2 

While Not KeyDown( 1 ) 

	x#=0 
	y#=0 
	z#=0 
	
	If KeyDown( 203 )=True Then x#=-0.1 
	If KeyDown( 205 )=True Then x#=0.1 
	If KeyDown( 208 )=True Then y#=-0.1 
	If KeyDown( 200 )=True Then y#=0.1 
	If KeyDown( 44 )=True Then z#=-0.1 
	If KeyDown( 30 )=True Then z#=0.1 
	
	MoveEntity ellipsoid,x#,y#,z# 
	
	; Perform collision checking 
	UpdateWorld 
	
	RenderWorld 
	
	Text 0,0,"Use cursor/A/Z keys to move ellipsoid" 
	
	Flip

Wend

End



eBusiness(Posted 1+ years ago)
Some of my old code still doesn't work, and there I use collision boxes, they will be streched like the sphere.

Edit:
Here is the collision box setup:
EntityBox csprite,-alphascale*.5,-betascale*.5,0,alphascale,betascale,1
SpriteViewMode csprite,2
EntityType csprite,xttt
And here is the collision sphere setup:
EntityRadius position,10,30


I can make a portable demo of the problem if you like.


fredborg(Posted 1+ years ago)
Seems like ebusiness is right:
; EntityRadius Example 
; -------------------- 

Graphics3D 640,480 
SetBuffer BackBuffer() 

camera=CreateCamera() 
light=CreateLight() 

CameraProjMode camera,2
CameraZoom camera,0.2

cube=CreateCube() 
EntityType cube,type_cube
PositionEntity cube,0,0,5 
EntityBox cube,-1,-1,-1,2,2,2

ellipsoid=CreateSphere( 32 ) 
PositionEntity ellipsoid,-2,0,5 

; Set radius values 
xradius#=1 
yradius#=1.5

; Set ellipsoid scale and entity radius to same as radius values
ScaleEntity ellipsoid,xradius#,yradius#,1.0
EntityRadius ellipsoid,xradius#,yradius#

; Set collision type values 
type_ellipsoid=1 
type_cube=3 

; Set ellipsoid and cone entity types 
EntityType ellipsoid,type_ellipsoid 
EntityType cube,type_cube

; Enable collisions between type_ellipsoid and type_cone, with ellipsoid->polygon method and slide response 
Collisions type_ellipsoid,type_cube,3,2 

While Not KeyDown( 1 ) 

	x#=0 
	y#=0 
	z#=0 
	
	If KeyDown( 203 )=True Then x#=-0.1 
	If KeyDown( 205 )=True Then x#=0.1 
	If KeyDown( 208 )=True Then y#=-0.1 
	If KeyDown( 200 )=True Then y#=0.1 
	If KeyDown( 44 )=True Then z#=-0.1 
	If KeyDown( 30 )=True Then z#=0.1 
	
	MoveEntity ellipsoid,x#,y#,z# 
	
	; Perform collision checking 
	UpdateWorld 
	
	RenderWorld 
	
	Text 0,0,"Use cursor/A/Z keys to move ellipsoid" 
	
	Flip

Wend

End
It looks like the collision box for the cube is scaled?

Maybe this should be moved to the bug reports instead...


eBusiness(Posted 1+ years ago)
Ah, I hadn't noticed it's now working with other stuff, the problem was on the bugs forum some months ago, before 1.86. Was it partially fixed then, or has it always only been with collision boxes?


H. T. U.(Posted 1+ years ago)
I just bought the full version of Blitz3D. Now this code doesn't work:

EntityRadius soldier,0.4,0.9

When I try to run it, I get an error message saying that it has too many parameters. But if I delete the y_radius#, it runs just fine.

Another thing: the command reference help page only shows the x_radius#. There is no mention whatsoever of a y_radius#.


TomToad(Posted 1+ years ago)
Sounds like you possibly downloaded an old version. At the top of this page, click on Account, then Product Updates and make sure you get the latest Blitz release as well as the latest Doc packs.


H. T. U.(Posted 1+ years ago)
Thanks TomToad!!!!


Ben(t)(Posted 1+ years ago)
entityradius ignores the y setting when I try to use it what is going on???
I have the most recent update the program runs but the y setting is ignored


Damien Sturdy(Posted 1+ years ago)
How do you know?


Ben(t)(Posted 1+ years ago)
because I had a figure that I wanted a wide x radius because it was long and a small y radius because it was supposed to touch the ground but it never would no matter what I tried if would always float


Blitz3D Manual Forum

BlitzPlus Equivalent Command