Posted: 30th Jul 2023 16:26
I would create 6 invisible objects like small boxes or planes surrounding the main player and object ray cast between the main player and those surrounding objects. Ok this maybe time consuming or even memory consuming cause we will have of their vertexes added to it too. But if they are invisible then shouldn't really matter.

Put these 0.5, 0.5, 0.5 size invisible boxes, below, forward, behind, to the left and right of the main object/player not too close or too far from its origin, something like 1.0 unit away.

The object ray cast should then hit if another object in the scene passes through these and then do what you need to do to the player if does collide, like jump or something.

The idea is simple, programming it would be challenging, but is definitely achievable.

I've seen something done like this before now and works pretty ok for collision detection between other visible objects

Edit .
Found this snippet


+ Code Snippet
Aidan/// Project: Mesh Template
// Created: 2019-01-12

// show all errors
SetErrorMode(2)

#constant screenwidth=1024
#constant screenheight=768
#constant fullscreen=0
#constant screenrate=0
#constant size=64  // Size of the chunk in X and Z direction - make this small so the chunk can be quickly rebuilt in processing
#constant renderdistance=0 // how many chunks surrounding each other - call it render distance variable

// set window properties
SetWindowTitle( "Mesh Template" )
SetWindowSize( screenwidth, screenheight, fullscreen )
SetWindowAllowResize( 1 ) // allow the user to resize the window

// set display properties
SetVirtualResolution( screenwidth, screenheight ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( screenrate, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts

global angx#,angy#,startx#,starty#
global camerax#,cameray#,cameraz#


// meshmemblock types
Type Vertex
    air as integer  
    x as float
    y as float
    z as float
    nx as float
    ny as float
    nz as float
    u as float
    v as float
endtype
  
Type Triangle
    v1 as integer
    v2 as integer
    v3 as integer
endtype
  
Type Mesh
    VertexList as Vertex[]
endtype
  
global MeshID as Mesh


// create player collisions units all way raround the player
for a=6 to 12
	CreateObjectBox(a,10,10,10)
	SetObjectVisible(a,0)
next


img = createtexture()

SetImageMagFilter(img,0)
SetImageMinFilter(img,0)


startx#=screenwidth/2
starty#=screenheight/2
SetRawMousePosition(startx#,starty#)

vortexposx=random2(-size+5,size-5)
vortexposz=random2(-size+5,size-5)

for x=-size to size
	for y=0 to 1
		for z=-size to size
				

			if y=1
				if random(0,100)>70 
					if x<>vortexposx and z<>vortexposz
						addCubeToMesh(x,random(y,y+1),z,1,1,1,1)
					endif
				endif
			else
				if x=vortexposx and z=vortexposz
					// dont add a cube - make a space in the ground
				else
				
					addCubeToMesh(x,y,z,1,1,1,1)
				endif
			endif	
		next
	next
next



obj=CreateObjectFromMeshWithUVTexturing(meshid,1,img)

camerax#=0
cameray#=5
cameraz#=-10
speed#=.01


SetCameraRange(1,.01,1000)
do
	
	    if ( GetPointerPressed() )
        startx# = GetPointerX()
        starty# = GetPointerY()
        angx# = GetCameraAngleX(1)
        angy# = GetCameraAngleY(1)
        pressed = 1
     endif
	
	        // get player input
	//if ( checkCollisionv2(obj,6,9)<>1 and GetRawKeyState( 38 ) ) then MoveCameraLocalZ( 1, speed# )  // cursor up
     //if ( checkCollisionv2(obj,6,10)<>1 and GetRawKeyState( 40 ) ) then MoveCameraLocalZ( 1, -speed# ) // cursor down
     //if ( checkCollisionv2(obj,6,11)<>1 and GetRawKeyState( 37 ) ) then MoveCameraLocalX( 1, -speed# ) // cursor iz
     //if ( checkCollisionv2(obj,6,12)<>1 and GetRawKeyState( 39 ) ) then MoveCameraLocalX( 1, speed# )  // cursor derecha 
  		if checkCollisionv2(obj,6,11)<>1 and GetRawKeyState(37) then dec camerax#,speed#
		if checkCollisionv2(obj,6,12)<>1 and GetRawKeyState(39) then inc camerax#,speed#
		if checkCollisionv2(obj,6,10)<>1 and GetRawKeyState(40) then dec cameraz#,speed#
		if checkCollisionv2(obj,6,9)<>1 and GetRawKeyState(38) then inc cameraz#,speed#
		if checkCollisionv2(obj,6,8)<>1 and GetRawKeyState(87) 
			MoveCameraLocalY(1,speed#)
			inc cameray#,speed#
			jumping=1
		endif

// check if hits the ground by checking the collisioner underneath camera
		if jumping=0 and checkCollisionv2(obj,6,7)<>1
			 MoveCameraLocalY(1,-speed#)
			 dec cameray#,speed#
		else
			jumping=0
		endif

		setcameradata()
		
	
	movecamera()
    Print( ScreenFPS() )
    Sync()
loop

function setcameradata()
		SetCameraPosition(1,camerax#,cameray#,cameraz#)
		camerax#=getcamerax(1)
		cameray#=getcameray(1)
		cameraz#=getcameraz(1)
		
		//collision object centre 
		SetObjectPosition(6,camerax#,cameray#,cameraz#)
		//collision object bottom
		SetObjectPosition(7,camerax#,cameray#-.5,cameraz#)
		//collision object above
		SetObjectPosition(8,camerax#,cameray#+.5,cameraz#)
		//collision object front
		SetObjectPosition(9,camerax#,cameray#,cameraz#+.5)
		//collision object behin
		SetObjectPosition(10,camerax#,cameray#,cameraz#-.5)
		//collision object left
		SetObjectPosition(11,camerax#-.5,cameray#,cameraz#)
		//collision object right
		SetObjectPosition(12,camerax#+.5,cameray#,cameraz#)
endfunction

function movecamera()
	if GetPointerState()=1
	fDiffX# = (GetPointerX() - startx#)/4.0
    fDiffY# = (GetPointerY() - starty#)/4.0
    newX# = angx# + fDiffY#
    if ( newX# > 89 ) then newX# = 89
    if ( newX# < -89 ) then newX# = -89
    SetCameraRotation(1, newX#, angy# + fDiffX#, 0 )
	endif
endfunction
function addCubeToMesh(x#,y#,z#,sizex#,sizey#,sizez#,c)
	
	
	// do adjacent culling check
	cx = floor(x#)
	cy = floor(y#)
	cz = floor(z#)
	
	
	AddVertex(meshid, x#-(sizex#/2)  		,y#+(sizey#/2)			,z#+(sizez#/2) 			, 0,1,0, 0	,0		, c)
	AddVertex(meshid, x#-(sizex#/2)  		,y#+(sizey#/2)			,z#+(sizez#/2)-sizez#	, 0,1,0, 0	,.5	, c)
	AddVertex(meshid, x#-(sizex#/2)+sizex#	,y#+(sizey#/2)			,z#+(sizez#/2) 			, 0,1,0, .5  ,0		, c)

	AddVertex(meshid, x#-(sizex#/2)+sizex#	,y#+(sizey#/2)			,z#+(sizez#/2) 			, 0,1,0, .5 ,0		, c)
	AddVertex(meshid, x#-(sizex#/2)  		,y#+(sizey#/2)			,z#+(sizez#/2)-sizez#	, 0,1,0, 0	,.5	, c)
	AddVertex(meshid, x#-(sizex#/2)+sizex#	,y#+(sizey#/2)			,z#+(sizez#/2)-sizez# 	, 0,1,0, .5 ,.5	, c)

	// BOTTOM face - top right corner texture
	AddVertex(meshid, x#-(sizex#/2)			,y#+(sizey#/2)-sizey#	,z#+(sizez#/2)			, 0,1,0, 0.5,0  	, c)
	AddVertex(meshid, x#-(sizex#/2)+sizex#	,y#+(sizey#/2)-sizey#	,z#+(sizez#/2) 			, 0,1,0, 1,0		, c)
	AddVertex(meshid, x#-(sizex#/2)			,y#+(sizey#/2)-sizey#	,z#+(sizez#/2)-sizez#	, 0,1,0, 0.5,0.5	, c)

	AddVertex(meshid, x#-(sizex#/2)+sizex#	,y#+(sizey#/2)-sizey#	,z#+(sizez#/2)			, 0,1,0, 1,0		, c)
	AddVertex(meshid, x#-(sizex#/2)+sizex#	,y#+(sizey#/2)-sizey#	,z#+(sizez#/2)-sizez#	, 0,1,0, 1,0.5		, c)
	AddVertex(meshid, x#-(sizex#/2)			,y#+(sizey#/2)-sizey#	,z#+(sizez#/2)-sizez#	, 0,1,0, 0.5,0.5		, c)


	// Left Side - bottom left corner texture
	AddVertex(meshid, x#-(sizex#/2)			,y#+(sizey#/2)			,z#+(sizez#/2) 			, 0,1,0, 0,0.5, c)
	AddVertex(meshid, x#-(sizex#/2)+sizex#	,y#+(sizey#/2)			,z#+(sizez#/2) 			, 0,1,0, 0.5,0.5, c)
	AddVertex(meshid, x#-(sizex#/2)			,y#+(sizey#/2)-sizey#	,z#+(sizez#/2)			, 0,1,0, 0,1, c)
	

	AddVertex(meshid, x#-(sizex#/2)+sizex#	,y#+(sizey#/2)			,z#+(sizez#/2) 			, 0,1,0, 0.5,0.5, c)
	AddVertex(meshid, x#-(sizex#/2)+sizex#	,y#+(sizey#/2)-sizey#	,z#+(sizez#/2) 			, 0,1,0, 0.5,1, c)
	AddVertex(meshid, x#-(sizex#/2)			,y#+(sizey#/2)-sizey#	,z#+(sizez#/2)			, 0,1,0, 0,1, c)
		
	// Right Side - bottom left corner texture
	AddVertex(meshid, x#-(sizex#/2)			,y#+(sizey#/2)			,z#+(sizez#/2)-sizez#	, 0,1,0, 0,0.5, c)
	AddVertex(meshid, x#-(sizex#/2)			,y#+(sizey#/2)-sizey#	,z#+(sizez#/2)-sizez#	, 0,1,0, 0,1, c)
	AddVertex(meshid, x#-(sizex#/2)+sizex#	,y#+(sizey#/2)			,z#+(sizez#/2)-sizez# 	, 0,1,0, 0.5,0.5, c)

	AddVertex(meshid, x#-(sizex#/2)+sizex#	,y#+(sizey#/2)			,z#+(sizez#/2)-sizez# 	, 0,1,0, 0.5,0.5, c)
	AddVertex(meshid, x#-(sizex#/2)			,y#+(sizey#/2)-sizey#	,z#+(sizez#/2)-sizez#	, 0,1,0, 0,1, c)
	AddVertex(meshid, x#-(sizex#/2)+sizex#	,y#+(sizey#/2)-sizey#	,z#+(sizez#/2)-sizez#	, 0,1,0, 0.5,1, c)

		
	// Front Side - bottom left corner texture
	AddVertex(meshid, x#-(sizex#/2)			,y#+(sizey#/2)			,z#+(sizez#/2) 			, 0,1,0   , 0    , 0.5, c)
	AddVertex(meshid, x#-(sizex#/2)			,y#+(sizey#/2)-sizey#	,z#+(sizez#/2) 			, 0,1,0   , 0    , 1  , c)
	AddVertex(meshid, x#-(sizex#/2)			,y#+(sizey#/2)-sizey#	,z#+(sizez#/2)-sizez#	, 0,1,0   , .5 , 1  , c)

	AddVertex(meshid, x#-(sizex#/2)			,y#+(sizey#/2)-sizey#	,z#+(sizez#/2)-sizez# 	, 0,1,0  , .5  , 1, c)
	AddVertex(meshid, x#-(sizex#/2)			,y#+(sizey#/2)			,z#+(sizez#/2)-sizez#  	, 0,1,0  , .5  , .5  , c)
	AddVertex(meshid, x#-(sizex#/2)			,y#+(sizey#/2)			,z#+(sizez#/2)		   	, 0,1,0  , 0    , .5  , c)

	// Back Side - bottom left corner texture
	AddVertex(meshid, x#-(sizex#/2)+sizex#	,y#+(sizey#/2)			,z#+(sizez#/2)			, 0,1,0   , 0   , 0.5, c)
	AddVertex(meshid, x#-(sizex#/2)+sizex#	,y#+(sizey#/2)-sizey#	,z#+(sizez#/2)-sizez#	, 0,1,0   , .5   , 1  , c)
	AddVertex(meshid, x#-(sizex#/2)+sizex#	,y#+(sizey#/2)-sizey#	,z#+(sizez#/2) 			, 0,1,0   , 0   , 1  , c)


	AddVertex(meshid, x#-(sizex#/2)+sizex#	,y#+(sizey#/2)-sizey#	,z#+(sizez#/2)-sizez# 	, 0,1,0  , .5   , 1, c)
	AddVertex(meshid, x#-(sizex#/2)+sizex#	,y#+(sizey#/2)			,z#+(sizez#/2)		   	, 0,1,0  , 0    , .5  , c)
	AddVertex(meshid, x#-(sizex#/2)+sizex#	,y#+(sizey#/2)			,z#+(sizez#/2)-sizez#	, 0,1,0  , .5  , .5 , c)


	
endfunction


function emptymesh()
	meshid.VertexList.length=-1
endfunction

Function AddVertex(m ref as Mesh, x as float, y as float, z as float, nx as float, ny as float, nz as float, u as float, v as float, air as integer)
    vert as vertex
    vert.x = x
    vert.y = y
    vert.z = z
    vert.nx = nx
    vert.ny = ny
    vert.nz = nz
    vert.u = u
    vert.v = v
    vert.air = air
    m.VertexList.Insert(vert)
  
endfunction
Function CreateObjectFromMeshWithUVTexturing(m ref as mesh, MeshIndex,texture)
    DeleteMemblock(chunkmesh)
    VertexCount = m.VertexList.Length + 1
   
    IndexCount = 0
    IndexOffset = 60 + VertexCount*36
    chunkmesh = CreateMemblock(IndexOffset+IndexCount*4)
    SetMemblockInt(chunkmesh,0,VertexCount)
    SetMemblockInt(chunkmesh,4,IndexCount)
    SetMemblockInt(chunkmesh,8,3)
    SetMemblockInt(chunkmesh,12,32) // no color - 36 if color
    SetmemblockInt(chunkmesh,16,60)
    SetMemblockInt(chunkmesh,20,IndexOffset)
    SetMemblockInt(chunkmesh,24,0x0c000300)
    SetMemblockString(chunkmesh,28,"position")
    SetMemblockInt(chunkmesh,40,0x08000300)
    SetMemblockString(chunkmesh,44,"normal")
    SetMemblockInt(chunkmesh,52,0x04000200)
    SetMemblockString(chunkmesh,56,"uv")
    //SetMemblockInt(memblock,60,0x08010401) // maybe one day or year in 2019 lol
    //SetMemblockString(memblock,64,"color") // maybe one day or year in 2019 lol
        for i = 0 to m.VertexList.Length
			
		if m.VertexList[i].air = 1 // has a block there
			SetMemblockFloat(chunkmesh,60+i*32,m.VertexList[i].x)
			SetMemblockFloat(chunkmesh,64+i*32,m.VertexList[i].y)
			SetMemblockFloat(chunkmesh,68+i*32,m.VertexList[i].z)
			SetMemblockFloat(chunkmesh,72+i*32,m.VertexList[i].nx)
			SetMemblockFloat(chunkmesh,76+i*32,m.VertexList[i].ny)
			SetMemblockFloat(chunkmesh,80+i*32,m.VertexList[i].nz)
			SetMemblockFloat(chunkmesh,84+i*32,m.VertexList[i].u)
			SetMemblockFloat(chunkmesh,88+i*32,m.VertexList[i].v)
		endif
        //SetMemblockInt(memblock,104+i*36,m.VertexList[i].color) //maybe one day or year in 2019 lol
    next
//    DeleteAllObjects()
	DeleteObject(1)
	
	

    CreateObjectFromMeshMemblock(1,chunkmesh)
    SetObjectImage(1,texture,0)
	SetObjectColor(1,255,255,255,10)
endfunction 1

function checkCollisionv2(objwith,objID as integer,objID2 as integer)
	start_x#=getobjectx(objID)
	start_y#=getobjecty(objID)
	start_z#=getobjectz(objID)

	end_x#=getobjectx(objID2)
	end_y#=getobjecty(objID2)
	end_z#=getobjectz(objID2)


// determine which object has been hit
	object_Hit = ObjectRayCast(objwith,start_x#,start_y#,start_z#,end_x#,end_y#,end_z#)

endfunction object_Hit

function createtexture()

countx=2
	
	
	stp = 1
	//top - grass top
	for x=0 to 16 step stp
		for y=0 to 16 step stp
		//	if random(1,0)=1
				c=MakeColor(0,random(100,200),0) // green
			//else
			//	c=MakeColor(random(200,255),random(200,255),random(200,255)) // white
			//endif	
			
			DrawBox(x,y,x+4,y+4,c,c,c,c,1)
		next
	next
	
	//bottom - dirt
	for x=16 to 32 step stp
		for y=0 to 16 step stp
			c=MakeColor(random(100,140),random(30,130),0)
			DrawBox(x,y,x+4,y+4,c,c,c,c,1)
		next
	next


// 3 sides - a bit of green at top and orange at bottom
	for x=0 to 16 step stp
		for y=16 to 32 step stp
			if y<20
				if random(0,10)>1
					c=MakeColor(0,random(100,200),0)
				else
					c=MakeColor(random(100,140),random(30,130),0)
				endif
						
			else
				c=MakeColor(random(100,140),random(30,130),0)
			endif
			DrawBox(x,y,x+4,y+4,c,c,c,c,1)
		next
	next



	
	img = GetImage(0,0,32,32)
	SaveImage(img,"test.png")
endfunction img




Aidan
Posted: 30th Sep 2023 13:45
Late post but thought I'd have a go.

I also used a ray to get ID and distance.

This one will identify near objects all around.

+ Code Snippet
// Project: IDcheck 
// Created: 23-09-30

SetErrorMode(2)
width# = GetMaxDeviceWidth()
height# = GetMaxDeviceHeight()
SetWindowSize(width#,height#,1)
SetVirtualResolution(width#,height#)
SetSyncRate(30,0)
SetScissor(0,0,0,0)
UseNewDefaultFonts(1)
Create3DPhysicsWorld()
Set3DPhysicsGravity(0,-0.15,0)
SetGenerateMipmaps(1)
SetSkyboxVisible(1)
SetSkyBoxHorizonColor(100,100,255)
SetSkyBoxSkyColor(100,100,255)
setprintsize(height#/25)

light1=1
CreatePointLight(light1,0,1000,0,10000,255,255,255)
SetPointLightMode(light1,1)

ground=1000
createobjectplane(ground,700,700)
setobjectcolor(ground,40,100,40,255)
rotateobjectlocalX(ground,90)
Create3DPhysicsStaticBody(ground)
setobjectshapebox(ground)
SetObjectCollisionMode(ground,1)


maxBoxes=50
//SetRandomSeed(11)
for i=1 to maxBoxes
    boxID=i+1000
    boxXpos=random(1,200)
    boxZpos=random(1,200)
    CreateObjectBox(boxID,7,7,7)
    SetObjectposition(boxID,boxXpos,-2,boxZpos)
    setobjectcolor(boxID,random(50,200),random(50,200),random(50,200),255)
    Create3DPhysicsStaticBody(boxID)
next i

cam1=1
SetCameraRange(cam1,0.1, 50000 )
SetCameraposition(cam1,0,30,0)
SetCameraRotation(cam1,0,0,0)

man1=CreateObjectsphere(2,6,12)
SetObjectposition(man1,0,30,0)
setobjectvisible(man1,0)
SetObjectRotation(man1,0,0,0)
Create3DPhysicsDynamicBody(man1)
SetObject3DPhysicsCanSleep(man1,0)
ovec = CreateVector3(0,0,0)
rvec = CreateVector3(0,0,0)
Create3DPhysicsCharacterController(man1,1,ovec,rvec,0.5)
Set3DPhysicsCharacterControllerJumpSpeed(man1,1)
Set3DPhysicsCharacterControllerFallSpeed(man1,3)
Set3DPhysicsCharacterControllerGravity(man1,1)
SetObjectCollisionMode(man1,1)
SetObject3DPhysicsMass(man1,2)


setrawmousevisible(0)
SetRawMousePosition(width#/2,height#/2)

do

    //  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx  cam control

    mouseX# = (GetRawMouseX()-width#/2)*0.2:mouseY# = (GetRawMouseY()-height#/2)*0.2 
    RotateCameraLocalX(cam1,mouseY#)
    SetCameraRotation(cam1,GetCameraAngleX(cam1),GetObjectAngleY(man1),0)
    If GetCameraAngleX(cam1)>80 Then SetCameraRotation(cam1,80,GetCameraAngleY(cam1),0)
    If GetCameraAngleX(cam1)<-80 Then SetCameraRotation(cam1,-80,GetCameraAngleY(cam1),0)
    strafe# = (GetRawKeyState(68) - GetRawKeyState(65)):move# = (GetRawKeyState(87) - GetRawKeyState(83))
    Move3DPhysicsCharacterController(man1,strafe#,move#,30)
    Rotate3DPhysicsCharacterController(man1,GetCameraAngleY(cam1)+mouseX#)
    
    if GetRawKeyPressed(32)
        Jump3DPhysicsCharacterController(man1)
    endif
    SetCameraPosition(cam1,GetObjectX(man1),GetObjectY(man1)+1,GetObjectZ(man1))
    
    //  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx  check close proximity and ID
    
    HitID=0
    dist# = 1000
    for c=0 to maxBoxes
        if c=0
            ray = ObjectRayCast(c+1000,getobjectworldX(man1),getobjectworldY(man1),getobjectworldZ(man1),getobjectworldX(man1),getobjectworldY(man1)-2,getobjectworldZ(man1))
        else
            ray = ObjectRayCast(c+1000,getobjectworldX(man1),getobjectworldY(man1),getobjectworldZ(man1),getobjectworldX(c+1000),getobjectworldY(c+1000),getobjectworldZ(c+1000))
        endif
        dist# = GetObjectRayCastDistance(0)
        if dist#<3.5      //  set detection range
            HitID=c+1000
            exit
        endif
    next c
    
    //  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    
    print(" Mouse WASD Space")
    print(" HitID "+str(HitID))
    if HitID=1000 then print(" on ground")
    
    Step3DPhysicsWorld()
    SetRawMousePosition(width#/2,height#/2)
    Sync()
    if GetrawKeyPressed(27) then end
loop



EDIT: tweeked the code for accuracy trying to detect only what is below feet.

+ Code Snippet
// Project: IDcheck 
// Created: 23-09-30

SetErrorMode(2)
width# = GetMaxDeviceWidth()
height# = GetMaxDeviceHeight()
SetWindowSize(width#,height#,1)
SetVirtualResolution(width#,height#)
SetSyncRate(30,0)
SetScissor(0,0,0,0)
UseNewDefaultFonts(1)
Create3DPhysicsWorld()
Set3DPhysicsGravity(0,-0.15,0)
SetGenerateMipmaps(1)
SetSkyboxVisible(1)
SetSkyBoxHorizonColor(100,100,255)
SetSkyBoxSkyColor(100,100,255)
setprintsize(height#/25)

light1=1
CreatePointLight(light1,0,1000,0,10000,255,255,255)
SetPointLightMode(light1,1)

ground=1000
createobjectplane(ground,700,700)
setobjectcolor(ground,40,100,40,255)
rotateobjectlocalX(ground,90)
Create3DPhysicsStaticBody(ground)
setobjectshapebox(ground)
SetObjectCollisionMode(ground,1)


maxBoxes=50
//SetRandomSeed(11)
for i=1 to maxBoxes
    boxID=i+1000
    boxXpos=random(1,200)
    boxZpos=random(1,200)
    CreateObjectBox(boxID,7,7,7)
    SetObjectposition(boxID,boxXpos,-2,boxZpos)
    setobjectcolor(boxID,random(50,200),random(50,200),random(50,200),255)
    Create3DPhysicsStaticBody(boxID)
next i

cam1=1
SetCameraRange(cam1,0.1, 50000 )
SetCameraposition(cam1,0,30,0)
SetCameraRotation(cam1,0,0,0)

man1=CreateObjectsphere(2,6,12)
SetObjectposition(man1,0,30,0)
setobjectvisible(man1,0)
SetObjectRotation(man1,0,0,0)
Create3DPhysicsDynamicBody(man1)
SetObject3DPhysicsCanSleep(man1,0)
ovec = CreateVector3(0,0,0)
rvec = CreateVector3(0,0,0)
Create3DPhysicsCharacterController(man1,1,ovec,rvec,0.5)
Set3DPhysicsCharacterControllerJumpSpeed(man1,1)
Set3DPhysicsCharacterControllerFallSpeed(man1,3)
Set3DPhysicsCharacterControllerGravity(man1,1)
SetObjectCollisionMode(man1,1)
SetObject3DPhysicsMass(man1,2)


setrawmousevisible(0)
SetRawMousePosition(width#/2,height#/2)

do

    //  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx  cam control

    mouseX# = (GetRawMouseX()-width#/2)*0.2:mouseY# = (GetRawMouseY()-height#/2)*0.2 
    RotateCameraLocalX(cam1,mouseY#)
    SetCameraRotation(cam1,GetCameraAngleX(cam1),GetObjectAngleY(man1),0)
    If GetCameraAngleX(cam1)>80 Then SetCameraRotation(cam1,80,GetCameraAngleY(cam1),0)
    If GetCameraAngleX(cam1)<-80 Then SetCameraRotation(cam1,-80,GetCameraAngleY(cam1),0)
    strafe# = (GetRawKeyState(68) - GetRawKeyState(65)):move# = (GetRawKeyState(87) - GetRawKeyState(83))
    Move3DPhysicsCharacterController(man1,strafe#,move#,30)
    Rotate3DPhysicsCharacterController(man1,GetCameraAngleY(cam1)+mouseX#)
    
    if GetRawKeyPressed(32)
        Jump3DPhysicsCharacterController(man1)
    endif
    SetCameraPosition(cam1,GetObjectX(man1),GetObjectY(man1)+1,GetObjectZ(man1))
    
    //  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx  check close below feet and get ID
    
    HitID=0
    dist# = 1000
    for c=0 to maxBoxes
        ray = ObjectRayCast(c+1000,getobjectworldX(man1),getobjectworldY(man1),getobjectworldZ(man1),getobjectworldX(man1),getobjectworldY(man1)-2,getobjectworldZ(man1))
        dist# = GetObjectRayCastDistance(0)
        if dist#<3.5      //  set detection range
            HitID=c+1000
            exit
        endif
    next c
    
    //  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    
    //myXpos#=getobjectworldX(man1)
    //myYpos#=getobjectworldY(man1)
    //myZpos#=getobjectworldZ(man1)
    //print(" XYZ "+str(myXpos#)+"  "+str(myYpos#)+"  "+str(myZpos#))
    
    print(" Mouse WASD Space")
    print(" HitID "+str(HitID))
    if HitID=1000 then print(" on ground")
    
    Step3DPhysicsWorld()
    SetRawMousePosition(width#/2,height#/2)
    Sync()
    if GetrawKeyPressed(27) then end
loop
Posted: 30th Sep 2023 22:00
Yes and hello, a long while but thought I would check in to see what's new.

What I do is use a distance formula and do not use collision as it uses to much system memory to keep checking plus it does not work well.

So if each object is to close to each other something happens. collision is based on touching each other and distance is the same thing.

There are real good distance functions on here it is up to you to test them all.

I hope this helps you.

I usually do not post much for others but I figured this out a while back so thought to help is possible.