Playing an animation for opening a door

Blitz3D Forums/Blitz3D Programming/Playing an animation for opening a door

nrasool(Posted 2005) [#1]
Hi there

Just been playing in Blitz and just wants some advice.

If i have a hero who steps at a certain stops, playing an opening animation, then the door opens, how will i do this.

Before asking, i tried to do this, by following code in my main loop

	If ((playerx=-287) And (playery=5) And (playerz > 229) And (playerz<250)) Then
		Animate player_hero,3,10,7
		While Animating(player)=0 Then
			RotateEntity door1,0,90,0			
		Wend
		
	End If


But it does not work, i just want, when the player enter the 'hotspot' the character stops, and plays an animation, so even if you press up,down,left,right it has no effect, once the animation is finished, then the door creaks open.

For the door i was thinking and tried

for door1_number=1 to 90 then
RotateEntity door1,door1_number,0
next

But again, i want the door to open, the above code does it fast, i had tried delay command, but thats does not work

Any help will be much appreciated :)

Kind Regards


Strider Centaur(Posted 2005) [#2]
Well your not rotating until the animation stops, try just doing a:

While Animatin(player)

Without the zero.


GitTech(Posted 2005) [#3]
Something like:

for door1_number#=1 to 90 step 0.1 then
    RotateEntity door1,0,door1_number#,0
next


Instead of:

for door1_number=1 to 90 then
    RotateEntity door1,door1_number,0
next



nrasool(Posted 2005) [#4]
Thanks for the information, Strider Centaur and GitTech

@Strider
I wanted to do this, play the hero animation first, then the door will open.
So the steps are:

1. Walk to hotspot
2. Player control stops
3. Player plays an opening animation.
4. Door opens
5. Player control resumes

Any idea on doing this?

@GitTech, thanks for this.

Kind Regards


Strider Centaur(Posted 2005) [#5]
Hmm sounds like a case for states

Or good ole Select Case of state in this case. hehe, err sorry.

Simply have a state variable that gets set for each step then feed that into a select case, in this instance 2 steps with the first state set by entering the hotspot.

Global doorstate = 0  ; not waiting for a door to open

If ((playerx=-287) And (playery=5) And (playerz > 229) And (playerz<250)) Then
   doorstate = 1
End If
doortest()

Function doortest()
    If doorstate = 0 Then
       Return
    Else
       Select doorstate
            Case 1:  ;start player animation at door
                 Animate player_hero,3,10,7
                 doorstate = 2
                 Return
            Case 2:  ; ok see if still animating
                 If Not Animating(player)Then
                     ; if not start opening door
                      doorstate = 0
                       For door1_number#=1 To 90 Step 0.1                  
                         RotateEntity door1,0,door1_number#,0
                       Next

                 EndIf
                 Return
			Default
     End Select
   End If
End Function



Well not sure if this will run, But I think it will give the idea.

Oh yea and if doorstate is not 0 then dont allow player controls.