AlignToVector Example


👉 BlitzCoder will be building a new platform and other plans to preserve and continue the Blitz legacy.

To be able to achieve this goal, we need your support by becoming a Patreon Paid Member 👈

 

Tweet blitz3d blast3d
RasterRon

A basic AlignToVector example with collision normals, also works with Blast3D.

; AlignToVector Example
; ---------------------

Graphics3D 640,480,0,2

camera = CreateCamera()
MoveEntity camera,0,0,-95
light = CreateLight()

SPHERE_COL=1 : CUBE_COL=2
collisionmethod=2 : collisionresponse=2
sphereposition=0 : spherespeed=0

mybox=CreateCube()  
ScaleMesh mybox,50,50,50    
FlipMesh(mybox)
UpdateNormals(mybox)
EntityColor mybox,0,128,0
EntityType mybox,CUBE_COL,0

sphere=CreateSphere()
ScaleEntity sphere,2,2,2,0
MoveEntity sphere,0,-.5,0
EntityColor sphere,0,0,255
PositionEntity sphere,0,0,30,0
EntityType sphere,SPHERE_COL,0
EntityRadius sphere,2,2

Collisions SPHERE_COL,CUBE_COL,collisionmethod,collisionresponse

While Not KeyHit(1)

    MoveEntity sphere,0.2,0.3,0.5

    If EntityCollided(sphere,CUBE_COL) Then
        AlignToVector sphere, CollisionNX(sphere, 1), CollisionNY(sphere, 1), CollisionNZ(sphere, 1), 1
    EndIf

    UpdateWorld
    RenderWorld
    Flip

Wend

Reply To Topic (minimum 10 characters)

Please log in to reply