Hilfe
Parameter
| entity% | Identität eines Objekts (entity) |
| x_radius# | XRadius der Kollisionsfläche |
| y_radius# | YRadius der Kollisionsfläche (ab Blitz3D 1.82) |
Rückgabewert
-
Beschreibung
Die Anweisung EntityRadius definiert eine kugelförmige (oder ellipsenförmige) Kollisionsfläche für ein Objekt.
In BlitzBasic gibt es zwei definierbare Kollisionsflächen: Quader (EntityBox
) und Kugel (EntityRadius). Hat man die Kollisionsfläche gewählt, dann kann man noch zusätzlich mit dem Befehl EntityType
den Kollisionstyp einstellen. Mit dem Befehl Collisions
wird die Kollisionsprüfung aktiviert.
Beispiel
Standardbeispiel:
SetBuffer BackBuffer()
camera = CreateCamera()
RotateEntity camera, 45, 0, 0
PositionEntity camera, 0, 15, - 10
light = CreateLight()
RotateEntity light, 45, 0, 0
sphere = CreateSphere(32)
EntityType sphere, 1
EntityRadius sphere, 1
PositionEntity sphere, 0, 11, 0
cube = CreateCube()
EntityType cube, 2
EntityColor cube, 0, 100, 0
PositionEntity cube, 0, - 5, 0
ScaleEntity cube, 10, 10, 10
cylinder = CreateCylinder(32)
EntityType cylinder, 2
EntityColor cylinder, 255, 0, 0
PositionEntity cylinder, 0, 7, 0
ScaleEntity cylinder, 2, 2, 2
Collisions 1, 2, 2, 2
While Not KeyDown(1)
x# = 0
y# = 0
z# = 0
If KeyDown(203) = 1 Then x# = - 0.1
If KeyDown(205) = 1 Then x# = 0.1
If KeyDown(208) = 1 Then z# = - 0.1
If KeyDown(200) = 1 Then z# = 0.1
MoveEntity sphere, x#, - 0.1, z#
UpdateWorld
RenderWorld
col = CountCollisions(sphere)
Text 0, 0, "Kollision(en):"
Text 300, 0, "1. Kollision mit:" + EntityCollided(sphere, 2)
For i = 1 To col
Text 000, i * 20, "Entity=" + CollisionEntity(sphere, i)
Text 150, i * 20, "Surface=" + CollisionSurface(sphere, i)
Text 300, i * 20, "Triangle=" + CollisionTriangle(sphere, i)
Next
Flip
Wend
End
Siehe auch
3D Grafik
Kollision
2D Grafik
3D Grafik