Hello all. I am having trouble playing an animation when a variable (alive#) turns to 0.
If Alive# = 0 then play object enemy#, 85, 100
(Note: that snippet is in my main loop). If I write "Loop object" it works fine... except for the fact that it loops and I only want the animation to run once, since it is the death animation.
What happens when I use the "play object" command, is it only seems to play the first frame or so then then it stops there..
It also seems to be playing my animation sideways :S... (Only on that animation), the others that I am using (I'm looping all the others) work perfectly.
Here is my code:
Rem Game Variables
`Map
Level# = 1
`Player
player# = 2
cam# = 1
Box# = 3
Box_End# = 4
`Physics
Grav# = -10
Momentum# = 0.0
forwback# = 0
sideside# = 0
`Controls
Max_Speed# = 4
RMax_Speed# = -4
Max_Inc# = .125
Max_Dec# = .125
`Camera
Cam_distance# = -200
`Enemy
Enemy# = 5
alive# = 1
Rem Load media
Load object "media\map\map.dbo", 1 `Load the map
Load Object "Media\obj\Enemy.3ds", enemy#
Rem Setup player
Make object box player#, 50,100,50 : Position object player#, 0,100,0 : Color object player#, rgb(255,0,0)
`Limbs
Make object box box#, 20,20,20 : Make Mesh from object 1,box# : Add limb player#, 1,1 : offset limb player#, 1,0,0,Cam_distance#
Hide object box# : hide limb player#, 1
Rem Setup camera
Make camera cam#
Set camera range Cam#,10,5000
Set camera FOV Cam#, 75
Rem Main loop
Do
Gosub Controls
Gosub Camera
Gosub GUI
Gosub Enemy
Loop
Controls:
`Old player pos
ox# = object position x(player#)
oy# = object position Y(player#)
oz# = object position Z(player#)
`Old Enemy pos
Eox# = object position x(enemy#)
Eoy# = object position Y(enemy#)
Eoz# = object position Z(enemy#)
Rem Acually move player
`Forwards or backwards
If forwback# > 0 then move object player#, forwback#
if forwback# < 0 then Move object player#, forwback#
`Side to side (left or right)
If sideside# > 0 then move object left player#, sideside#
if sideside# < 0 then Move object left player#, sideside#
Rem Controls
`Increasing/decreasing forward or backward momentum.
If keystate(17) and forwback# < Max_Speed# then Inc forwback#, Max_Inc# `Forward
If keystate(17)=false and forwback# > 0 then dec forwback#, Max_Dec#
If keystate(31) and forwback# > RMax_Speed# then Dec forwback#, Max_Inc# `Back
If keystate(31)=false and forwback# < 0 then inc forwback#, Max_Dec#
`Increasing/decreasing side to side momentum.
If keystate(30) and sideside# < Max_Speed# then Inc sideside#, Max_Inc# `Right
If keystate(30)=false and sideside# > 0 then dec sideside#, Max_Dec#
If keystate(32) and sideside# > RMax_Speed# then Dec sideside#, Max_Inc# `Left
If keystate(32)=false and sideside# < 0 then inc sideside#, Max_Dec#
`Mouse controls
Yrotate object player#, object angle Y(player#) + mousemovex()*.25
Return
Camera:
lOx# = Limb position x (player#,1) : lOy# = Limb position y (player#,1) : lOz# = Limb position z (player#,1)
Position camera cam#,lOx#,lOy#+900,lOz#
Rotate camera cam#,60,object angle y(player#),0
Return
GUI:
ReturnX# = EoX# - ox#
ReturnY# = EoZ# - oz#
Set cursor 10,10 : Print Screen FPS()
Set cursor 10,25 : Print forwback#
Set cursor 10,40 : Print sideside#
Set cursor 10,55 : Print "EoX#: ", EoX#
Set cursor 10,70 : Print "EoZ#: ", EoZ#
Set cursor 10,85 : Print "oX#: ", oX#
Set cursor 10,100 : Print "oZ#: ", oZ#
Set cursor 10,115 : Print "Return X#: ", ReturnX#
Set cursor 10,130 : Print "Return Z#: ", ReturnY#
Set cursor 10,145 : Print "Alive: ", Alive#
Return
Enemy:
Set object speed Enemy#, 10
If Alive# = 1 then Point object Enemy#, ox#,0,oz#
`Moves enemy
ReturnX# = EoX# - ox#
ReturnZ# = EoZ# - oz#
If ReturnX# > 75 and alive# = 1 then move object Enemy#, 1.5
If ReturnX# < -75 and alive# = 1 then move object Enemy#, 1.5
If ReturnY# > 75 and alive# = 1 then move object Enemy#, 1.5
If ReturnY# < -75 and alive# = 1 then move object Enemy#, 1.5
Rem attack/not attack - animations
`If enemy is out of range do not attack
If ReturnX# > 75 and alive# = 1 then loop object enemy#, 40,79
If ReturnX# < -75 and alive# = 1 then loop object enemy#, 40,79
If ReturnZ# > 75 and alive# = 1 then loop object enemy#, 40,79
If ReturnZ# < -75 and alive# = 1 then loop object enemy#, 40,79
`If enemy is in range attack
If ReturnX# < 75 and ReturnX# > -75 and alive# = 1 then Loop object enemy#, 0,15
If ReturnZ# < 75 and ReturnZ# > -75 and alive# = 1 then Loop object enemy#, 0,15
Rem Handles enemies death
if spacekey()= 1 then alive#=0
If Alive# = 0 then play object enemy#, 85, 100
Return
Thanks a lot!
ßõw§€r¥¤