[Tutorial] The State Actuator

Moderators: Yodaman921, Gabriel

[Tutorial] The State Actuator

Postby hydra_skillz » Wed Jan 14, 2009 8:21 pm

So, I was playing around with Blender and I figured out how to use the state actuator, it is really powerful! I thought I'd write a tutorial about it so you can use it in your games too. Not a pure beginner tutorial (I'm not going over hotkeys and such).

We (mostly you) are going to make a cube that, when you press 'shift', goes into running mode and back to walking when 'shift' is pressed again.

First, add a cube (or use default) and a plane (scale up 10-20 units). For ease of visibility, make the plane a different color than gray. Select the camera (or add one if needed) and position it above the cube and parent it to the cube. Select the cube and add three keyboard sensors make them w, s, and shift keys. To make things easier later name them “w key”, “s key”, and “shift” (you can minimize them now too). Add three controllers(only using 'and' controllers), two motion actuators (name them "fwrd walk" and "back walk"), and a state actuator (name it "running"). Link like in the picture.

tut1.jpg
Connections
tut1.jpg (49.36 KiB) Viewed 12505 times


Make the fwrd and back walk actuators Loc 0.1 in your forward direction and -0.08 in the backwards direction. Note that you could use just one motion actuator if you wanted the same forward and backwards speed. I am making mine different speeds for realism. Now for the running actuator. At first glance, it looks similar to the layers buttons (that you are hopefully familiar with). These layers correspond to the layers above our controllers. Set the running actuator to the second layer (also make sure it says 'Cpy'). Now go to the layers buttons above our controllers and select layer two, and notice that all the connections have disappeared. Add three more actuators - “walking” a state actuator with layer one selected, "fwrd run" and "back run" motion actuators (I used .3 and -.25 for my speeds). Link like in the picture.

tut2.jpg
Connections
tut2.jpg (54.91 KiB) Viewed 12507 times


Go to camera view and try it out. Hope you find them as cool and useful as I do. Below is for some practice.

Now try adding a duck mode. You will need to use a third logic layer, keyboard sensor, state actuator, and one or two motion actuators. After you get the movement working, add an ipo to the camera making it go down, and mix that into everything so ducking has the ducking effect. You will probably need to use property sensors and actuators to control the ipo actuators on the camera (like ducking equals true or false).
GE API <- reference for game engine scripting
User avatar
hydra_skillz
Premium Member
Premium Member
 
Posts: 1321
Joined: Mon Dec 15, 2008 5:22 pm
Location: North Carolina

Re: [Tutorial] The State Actuator

Postby loist » Thu Jan 15, 2009 8:43 am

Greate tutorial 8-) :geek:
...creation is the way to create something...

sorry for my bad speech, i'm lithuanian
Image
Image
User avatar
loist
Member
Member
 
Posts: 461
Joined: Thu Apr 03, 2008 11:16 am
Location: Kaunas - Šiauliai, Lithuania

Re: [Tutorial] The State Actuator

Postby Yodaman921 » Thu Jan 15, 2009 12:40 pm

Very good and easy to understand, I will have to apply some of this stuff into my game I'm working on.
Image
User avatar
Yodaman921
Site Admin
Site Admin
 
Posts: 2675
Joined: Sat May 17, 2008 8:49 pm
Location: University of Michigan

Re: [Tutorial] The State Actuator

Postby crazyfrog » Thu Apr 01, 2010 9:12 pm

i no that his was a bit late but great tutorial
i had no idea what states where
thnx u really helped me understand them
crazyfrog
Member
Member
 
Posts: 55
Joined: Tue Feb 09, 2010 1:37 am


Return to User Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest

cron