noobs & PointEntity

BlitzMax Modules Forums/MiniB3D/noobs & PointEntity

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

it's a bit complex to explane it but i'll try.

i've a series of 5 planets placed in line
actually those are defined as object, and are an array.
i've placed the camera a bit distant to see all planets, but i wish that on the mouse click the camera zoom on the picked entity.

to made this i've made a function "CameraMover"
Function CamMover:Int(cam:TCamera, X:Int , Y:Int , Z:Int,target:TEntity, Speed:Int=5) 
	'================== X =========================================================
	Local vX:Int, vY:Int, vZ:Int
	PointEntity(cam, target)
	If EntityX(cam) < X Then
		vX= X - EntityX(Cam) 
		If vX => speed Then
			PositionEntity (cam , EntityX(Cam) + speed , EntityY(Cam) , EntityZ(Cam) )
		End If
	Else	
		vX = EntityX(Cam) - X
		If vX => speed Then
			PositionEntity (cam , EntityX(Cam) - speed , EntityY(Cam) , EntityZ(Cam) )
		End If
	End If
	'================== Y =========================================================
	If EntityY(cam) < Y Then
		vY = Y - EntityY(Cam) 
		If vY => speed Then
			PositionEntity (cam , EntityX(Cam), EntityY(Cam) + speed , EntityZ(Cam) )
		End If
	Else	
		vY = EntityY(Cam) - Y
		If vY => speed Then
			PositionEntity (cam , EntityX(Cam), EntityY(Cam) - speed , EntityZ(Cam) )
		End If
	End If
	'================== Z =========================================================
	If EntityZ(cam) < Z Then
		vZ = Z - EntityZ(Cam) 
		If vZ => speed Then
			PositionEntity(cam , EntityX(Cam), EntityY(Cam) , EntityZ(Cam) + speed )
		End If
	Else	
		vZ = EntityZ(Cam) - Z
		If vZ => speed Then
			PositionEntity (cam , EntityX(Cam), EntityY(Cam) , EntityZ(Cam) - speed)
		End If
	End If
	DebugLog "vx:"+ vX +" vY:"+ vY +" xZ:"+ vZ
	If vX <= speed And vY <= speed And vZ <= speed Then
		Return 1
	Else
		Return 0
	End If
End Function

the function will return 1 when meet the destination.
It will be placed on the main loop, so the user will see the camera movement and will fly through the solar system.

i've to say also that i've declared a properties mesh on the object planets so i can reach it when i need, just like in this case.

Type tPlanet 
	Field ID:Int
	Field Name:String

	Field posX:Int
	Field posY:Int
	Field posZ:Int
	
	Field mass:Int					'planet size
	Field mesh:TEntity
        ...


and then the main code, inside the loop there is a check
if the user click on a planet moveCamera will be = 1 and then ...
If moveCamera = 1 Then
	If camMover(cam , camDest.X, camDest.Y , camDest.Z, Planet[Int(EntityName(entityPickata) )].mesh , 20) = 1 Then MoveCamera = 0
End If


but the problem is with PointEntity 'cause i get a Null object error.
Unhandled Exception:Attempt to access field or method of Null object

i hate this error <_<'