Posted: 13th Dec 2021 6:01
So generating terrains is real slow and takes a long time so I am loading them.

But I always fall through them and other stupid stuff.

How can i position my player to stay at the height of the loaded terrain?
Posted: 13th Dec 2021 6:57
GetObjectHeightMapHeight()
Posted: 13th Dec 2021 7:04
blink0k

It is not a generated height map terrain, it is a loaded one

So that did not work for me.

GetObjectHeightMapHeight
Description
If the object was created with CreateObjectFromHeightMap
Posted: 13th Dec 2021 7:06
see ObjectRayCast.

i noted a few user examples there, as well.

basically, shoot a ray down from above the terrain object to below the object and use GetObjectRayCastY for your height.

check the "decal" demo, there, which seems to be the most helpful.
Posted: 13th Dec 2021 7:14
Thanks Virtual Nomad

Ill check that out.
Posted: 13th Dec 2021 8:08
quickie:
+ Code Snippet
// Project: TerrainHeight 
// Created: 2021-12-12
// By: Virtual Nomad
// show all errors
SetErrorMode(2)

// set window properties
SetWindowTitle( "TerrainHeight" )
SetWindowSize( 1280,720, 0 )
SetWindowAllowResize( 1 )
MaximizeWindow()

// set display properties
SetVirtualResolution( 1280,720)
SetOrientationAllowed( 1, 1, 1, 1 )
SetSyncRate( 30, 0 ) 
SetScissor( 0,0,0,0 )
UseNewDefaultFonts( 1 ) 

terrain = CreateObjectFromHeightMap("YellowStone.png", 512,64,512,4,1)
SetObjectImage(terrain, LoadImage("YellowStone.png"),0 )
SetObjectCollisionMode(terrain,1)

cx# = 256.0	:	cz# = 256.0
ray = ObjectRayCast(terrain,cx#,128,cz#,cx#,-16,cz#)
cy# = GetObjectRayCastY(0)
SetCameraPosition(1,cx#,cy#+10,cz#)

do
    If GetRawKeyState(27) then Exit

    SetCameraRotation(1,0, GetCameraAngleY(1) + GetJoystickX()*2.0,0)
	angle# = GetCameraAngleY(1)
	
	if GetJoystickY() <> 0.0
		cx# = cx# + SIN(angle#)* -GetJoystickY()*2.0
		cz# = cz# + COS(angle#)* -GetJoystickY()*2.0
		ray = ObjectRayCast(terrain,cx#,128,cz#,cx#,-16,cz#)
		cy# = GetObjectRayCastY(0)
		SetCameraPosition(1,cx#,cy#+10,cz#)
	Endif

    Print("WASD")

    Sync()
loop


Posted: 13th Dec 2021 13:43
@Virtual Nomad Nice one !
@Game_Code_here you can use Virtual Nomand's example with hight maps ....if you want to go up your own terrain made in 3D Editor, you can use my example basic collision system


Cheers.
Posted: 13th Dec 2021 15:46
and, bullet is also an option.

it depends on all you're trying to do. if it's just getting the "height" of a terrain object, (standard) rays will do the job.
Posted: 13th Dec 2021 21:17
chafari

I am using physic's and I am good thank you.

it depends on all you're trying to do. if it's just getting the "height" of a terrain object, (standard) rays will do the job.


It just do not make any sense.

you give a object collision, it has a static collision set up but the player still falls through it.

But your example works good.

Thank you.

I will show something very soon I am proud of.
Posted: 13th Dec 2021 23:31
@GCH,

ando offered a nice bullet vehicle/terrain demo HERE. you might find some insight.

the player still falls through

in my experience, SetObject3DPhysicsCanSleep() and minimizing/not allowing rotation if there is no linear velocity are key.

i tend to SetObject3DPhysicsLinearVelocity() but i think bullet prefers motors (or other methods where it can determine velocity under the hood) whenever possible. the system seems to be less forgiving than what you (and i) might be used to with box2d, IMHO.