GetSurface Problem

Blitz3D Forums/Blitz3D Programming/GetSurface Problem

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.

I have a tank mesh with 2 surfaces.

One Surface is the basic paint job, the other is the texture for the tracks.
Function NewTank(x#,z#)
	t.Tank = New Tank
	t\id = GetNextID("Tank")
	t\Mesh = LoadAnimMesh("models\tank.b3d")
	t\w1 = FindChild(t\mesh,"W1")
	t\w2 = FindChild(t\mesh,"W2")
	t\w3 = FindChild(t\mesh,"W3")
	t\w4 = FindChild(t\mesh,"W4")
	t\w5 = FindChild(t\mesh,"W5")
	t\w6 = FindChild(t\mesh,"W6")
	t\w7 = FindChild(t\mesh,"W7")
	t\Turret = FindChild(t\mesh,"Turret")
	t\Barrel = FindChild(t\mesh,"Barrel")
	t\Aimer = CreatePivot(t\mesh)
	t\LastAim = CreatePivot(t\mesh)
	PositionEntity t\Aimer,EntityX(t\Barrel,True),EntityY(t\Barrel,True),EntityZ(t\Barrel,True)
	t\Track = GetSurface(t\Mesh,1)
	t\TrackTex = LoadTexture("models\track.png")
	t\TrackBrush = CreateBrush()
	BrushTexture t\TrackBrush,t\TrackTex
	PaintSurface t\Track,t\trackBrush
	PositionEntityOnGround(t\Mesh,x,z)
	t\EngineSound = EmitSound(snd_Tank,t\Mesh)
	t\EnginePitch = 11025
	t\EngineVolume = 0
	ChannelVolume t\EngineSound,0
End Function
This loads up the tank mesh, paints the track with the track texture. Then with the handle of the track texture per tank I can then move the texture to give the impression of the tracks rolling forward.

This works fine.

The problem however is on this line:
t\Track = GetSurface(t\mesh,1)

It seems for no good reason at all sometimes surface index 1 is the track and other times it's the paint job, there seems to be no rhyme or reason for this to suddenly swap. So I'll run the program once and everything looks fine, I'll run it again and the paint job is now a track texture moving all over it.

Is there any way to find the surface by name or something similar. This is doing my head in!