Home
Fusion 2.5+
Firefly+
Tutorials+
Videos+
Guides & Tips+
Extensions
Versions
Teaching


14: UP AND RUNNING

14: UP AND RUNNING


Our Waiter is in and facing the correct way, now we need to let the player control him. We need him to walk left and right now, so lets set a new condition Upon pressing a key when asked which key press the Left cursor key on your keyboard. Do the same again this time press the Right cursor key on your keyboard, for the left key Animation -> Play Animation by frame range and type 50 to 55, for the right key Animation -> Play Animation by frame range and type 60 to 65. although he now looks like hes walking he isnt actually moving so now we need to change his position as he walks.

     
   
     
Make a new condition only this time choose Repeat while key is pressed when asked choose the left cursor key and create another one for the right cursor key. in the grid square for the animated mesh and the repeat left condition select right mouse and choose Node properties -> Position -> Set X Co-ordinate be careful not to choose the Position near the top as that is the 2D Position not the 3D one.
     
   
     
To answer the expression you need to Right Mouse the animated mesh icon in the frame at the bottom and select Node properties -> Position -> Get X Co-ordinate again be careful not to choose the 2d one near the top.
     
   
     
Once thats done in the text window you need to add -1 as this will make the waiter move to the left. do the same for the Repeat while 'Right arrow' is pressed only add + 1 to make him move right.
     
   
     
Now you may have noticed if you run the program that the waiter can move all the way left and off screen and all the way right and off screen. We need to stop moving him  when he goes too far, to do this we can simply add a limit to the repeat while pressed command. Right click on Repeat while 'Left Arrow' is pressed and choose Insert we are now choosing a second rule to ensure he stays in the screen.
     
   
     
Right mouse the animated mesh icon and select Node properties -> Position -> Compare X Position to a value
     
   
     
Change the comparison method to Greater and enter a value of -170, this means that if the man goes too far left and his X location becomes smaller than -90 then dont let him walk anymore. Do the same for the right arrow but this time choose Lower than 150, if you did it correctly it should match mine below. Run the game and have a little test to see how he walks.
     
   
     
If we ignore the fact he slides along the floor, as he's supposed to do that, when you let go of the left or right button he stays with his leg in the air, lets fix that by adding a if the player lets go of any button then have him bounce in a little idle animation. To do this we need to set one of the animated mesh's State flag's whats a state flag i hear you ask, its basically just setting up in memory whether hes walking or not, so when we start walking we set the flag then when we stop moving we can unset it, right mouse the grid where Upon pressing "Left Arrow" and the Animated Mesh meet select Flags -> Set on leave the  popup at 0, do the same for Upon pressing "Right Arrow"
     
   
   

 

Right click on New condition then right click on the animated mesh icon select Alterable Values -> Flags -> Is flag on?, again leave the default 0 in the popup window.

     
   
     

Normally at this stage we would put a tick into one of the grids, however we haven't actually finished the condition yet as so far we just have is the player walking, what we actually need is the player walking and not pressing any direction buttons. lets add a check for the left arrow not being pressed, right mouse the condition we just added and select Insert.
 

     
   
     

The check we need is if player isnt pressing left arrow however if you look at the keyboard object we only have if keys are pressed, however we can negate a condition so it means the opposite, so select The Keyboard -> Repeat while key is pressed when asked press the Left Arrow on the keyboard then right mouse it and select Negate it should have a red X next to it if you negated it properly.

     
   
     

Insert another  The Keyboard -> Repeat while key is pressed when asked press the Right Arrow on the keyboard then Negate it alsoOnce they are both negated choose the animated mesh grid square and set the Animation -> Play Animation by frame range between 30 and 50

     
   
     
Now we have checked if he was walking but has now stopped and changed him to do a bounce animation, we now need to set his flag back off, right click the animated mesh grid square again and select Flags -> Set Off, we currently have looping off which means he will only bounce once so we need right mouse again and select Animation -> Looping -> On. as we turned looping on it will mess up the walking as that was off so we need to go back to the  Upon pressing "Left Arrow" line and add in a Animation -> Looping -> Off. and also one for the  Upon pressing "Right Arrow" line. check your Playing Section looks like this.
     
   
     
When your done have a quick play we have the world, we have the floor and walls and now we have our player, WELL DONE all we need now is a ball and some bricks.
     
     
 

 




Spread the word!



You can share this document using the following buttons.




Submit your own User Tip