I'm trying to create a muzzle flash from a tank firing. Placing the flash at the end of the barrel is not too much of an issue.
What's currently confusing me is how to display a flash of light when the tank fires.
Code is as follows:
set display mode 800,600,32,1
set window on
sync on
sync rate 0
autocam off
position camera 0,15,-20
point camera 0,0,10
color backdrop rgb(0,0,0)
`tank
load object "3dmodels\tank.x", 1
load image "gfx\t80.bmp",1
texture object 1,1
scale object 1, 1.5,1.5,1.5
yrotate object 1, 180
set shadow shading on 1,-1,1000,1
position object 1, -4,0.25,5
`muzzle flasg
load image "gfx\flash2.png",2
make object plain 2,4,2
xrotate object 2, 45
texture object 2,2
set shadow shading off 2
SET ALPHA MAPPING ON 2, 60
make object plain 3,4,2
xrotate object 3,-45
texture object 3,2
set shadow shading off 3
SET ALPHA MAPPING ON 3, 60
`ground
make object plain 4, 80, 60
position object 4,0,0.10,24
xrotate object 4, 270
color object 4, rgb(128,128,128)
`second tank
load object "3dmodels\tank.x", 5
texture object 5,1
scale object 5, 1.5,1.5,1.5
yrotate object 5, 180
set shadow shading on 5,-1,1000,1
position object 5, 4,0.25,5
MuzzleLimbNumber= GetLimbNumber(1)
set ambient light 25
make light 1
set point light 1,-40,200,40
set light range 1,250
set shadow position 1,0,0,0
make light 2
set point light 2, object position x(2),object position y(2), object position z(2)
set light range 2,100
color light 2, 256,256,0
do
sync
loop
function GetLimbNumber(ObjectNum)
n=0
do
n=n+1
if limb exist(ObjectNum,n)
if limb name$(ObjectNum,n) = "FIRE01"
LimbNum = n
position object 2,LIMB POSITION X(ObjectNum, LimbNum)-1.5,LIMB POSITION Y(ObjectNum, LimbNum),LIMB POSITION Z(ObjectNum, LimbNum)
position object 3,LIMB POSITION X(ObjectNum, LimbNum)-1.5,LIMB POSITION Y(ObjectNum, LimbNum),LIMB POSITION Z(ObjectNum, LimbNum)
exit
endif
else
exit
endif
loop
endfunction LimbNum
Now that kind of works. A really weedy yellow light shines on the tank. But does the range really have to be 100? By the time I turn the range down so it doesn't affect other nearby objects, the light on the tank disappears. It also casts no glow on the ground plain.
Being new to this, I wouldn't be surprised to learn that I'm mis-understanding something and it would work if I changed my code a bit.
On the otherhand, I wouldn't be too surprised to learn that I need to buy Dark Lights in order to get a decent lighting solution