Clickable objects

Blitz3D Forums/Blitz3D Tutorials/Clickable objects

Jammer429(Posted 2014) [#1]
Hello, I was wondering how you would go about making some like say.. a door. If you click on the door it does something. I'am not sure how to make it clickable. Any help would be much appreciated.


Jammer429(Posted 2014) [#2]
I realize I posted this in the wrong place. My apologizes.


RemiD(Posted 2014) [#3]
The Blitz3D Beginners Area forum is more appropriate for this kind of questions.

You want to use a combination of EntityPickMode() and CameraPick() or LinePick().
EntityPickMode() is used to make a mesh "pickable".
CameraPick or LinePick is used to throw a ray from a point and then you can retrieve the picked "pickable" pointer, and infos about the pick (x,y,z,nx,ny,nz)

Preferably, you want to use a low tris mesh for each "pickable", or EntityRadius or EntityBox.


Jammer429(Posted 2014) [#4]
I've messed with those, but I'm having trouble trying to actually tie it to a keypress.


Rick Nasher(Posted 2014) [#5]
You could try something like this(pseudo code):

If KeyDown(28)=True and distance_to_object<door_range or collided_with_doorobject=true then

    MoveEntity Door, Xunits, 0,0

Endif

Where of course the enter key is being used to open the sliding door.


Jammer429(Posted 2014) [#6]
This has got me stumped. Blitz3d is the first language I've actually sit down and actually put effort into learning. So bare with me if I don't quite understand something. Thanks for the help I am getting. I really appreciate it.

Function Jail()													   ; Starting zone
	Cls 
	started = True                                                 ;Room
	PlayerData()
	FreeImage (start_btn)
	Cls 
	PlaySound(Jailsound)
	Jail = LoadMesh("Media\Meshes\Jail\Jail.b3d")
	PositionEntity(Jail,0,0,0)
	ScaleEntity(Jail,1.2,1.2,1.2)
	EntityType Jail, Type_Jail 
	
	
	box = CreateCube()                                             ; Clickable Test subject
	EntityPickMode box,2
	x = 0
	z = 5
	PositionEntity box,x,0,z
	ScaleEntity box,20,20,20
	
	If MouseHit(2) Then CameraPick(cam,MouseX(),MouseZ())
		
	
End Function



Rick Nasher(Posted 2014) [#7]
Perhaps this is something:

Code archives/3D Graphics - Mesh/Doors 101 - Simple multiple door system