How do YOU create your movement?

What is your method of choice for character movement? Simple motion? Servo controls? Python? What do you see as the most realistic way to create movement for a walking/running character? Thanks in advance!

Can someone help me please? I’d like to know how most people create their motion.

I rotate, translate and select character actions with python. Mostly because i require AI/pathfinding-driven characters which logic bricks don’t really cater for.

Even for simple player-camera movements i prefer to pass keypresses to a python script which then applies the appropriate motion, rather than use logic bricks.

I’ve seen some pretty cool and complex logic brick setups, but personally i’m more comfortable with python.

Well, I typically use a python script so I don’t have a big mess of logic bricks. I only need one actuator and one sensor. Here’s an example that typically use.

import GameLogic as g     #gives access to GameLogic module and names it g
 
cont = g.getCurrentController()    #gives access to logic bricks
kUP=146     #defines the key up
key = cont.getSensor('key')     #this is the sensor we will work with
move = cont.getActuator('move')    #this is the actuator we will work with
 
def Key(sen,key):    #This function checks if a key is pressed
 if sen.isPositive() == 1:
  if [key,1] in sen.getCurrentlyPressedKeys():
   return True
 if sen.isPositive() == 0:
  return False
 
def Motion(acc,x=0,y=0,z=0,local=True):    #This function controlls movment
 acc.setDLoc(x,y,z,local)
 add(acc,1)
 add(acc,0)
 
#main
if Key(key,kUP) == 1:    #checks if up is triggered
     Motion(move,x=.01)    #starts movement
if Key(key,kUP) == 0:    #turn off movement
    Motion(move)    #returns all vectors to zero

That’s how I do it. Those functions and more are in my script ‘BGESHORT.py’ if you want to try it. There is also the blengine module that makes this easier, it’s not by me but if you mention it, you’ll be pointed in the right direction. If you want to use mine I’ll post it. Mine isn’t perfect, but it’s good for a quick test.

For characters and such python + servo.
For objects that I just want to set into motion, simple motion (force)

I like servo motion.

I don’t know much python at all - but I really seen how easy it could be instead of visualising a mess or logic bricks - I’m in terested in checking out your script if it makes life a little easier -

Well I’ll post mine later today. I’m not at home right now so I don’t have the file.

Ok, I started a thread for my module: http://blenderartists.org/forum/showthread.php?p=1423491#post1423491
Hope it helps.

I find setting the linV values of a servo controller using Python works smoothly and gives good control. The script can also tweak the max/min force values too.

i use servo and the friction on the material of the character

Wow thanks for the responses guys! I’ll be sure to look into all of them, but I’d really like to hear about yours, moffboffjoe. I can get servo motion to work ok, but friction is my main problem. And the acceleration is rather unrealistic for a running character.

Friction should really be used to slow an object constantly, like… friction. :wink:

To quickly slow a running character, I’d use a servo controler with the linV set to 0. This linV value is the target velocity that you want your character to travel at. The max/min are the maximum and minimum forces that can be applied to achieve the target velocity (remember that for forces to apply along a negative axis you need to allow a negative minimum force). The PID values determine how abruptly the servo controller is allowed to change the force resulting in softer or more abrupt changes.

The servo actuator is actually a software implementation of a PID controller. I found that this guide for tuning PID controllers was very informative for explaining these seemingly complex but incredibly powerful devices.

I’ve set up a mockup of a force based space ship control system for following an Ipo path in the game engine that I might use in a tunnel-based Gyruss clone. This would be incredibly complex to do using any other system available to the game engine. I present this as an example that although servos appear complex at first they are well worth the initial learning curve for the control that they give the game developer.

Wow! I think I finally understand servo controls. I’ll look into your links in a bit. Thanks!

EDIT:
Your second link isn’t working for me… it gives me a 404 error from the host.

Oops. Made a mistake in the address. It should work now. :wink:

It’s implementation is specific to electronics applications, but it gives good explanations of the various aspects in a concise and readable way. If looked at as an example of a different application of PID controllers then it should be pretty helpful. Hope this helps.

Good luck. :slight_smile:

Thanks FunkyWyrm! I have to say though, that PID manual looks a bit over my head. Maybe once I get to calculus. Good to have though! I need to re-find this one thing I saw a while ago about servo controls. That kind of helped me, except I still had no idea how servo controls worked or what PID even did.

So whats the difference from simple motion and servo motion?

I believe servo uses a combination of velocity, instead of force…

It really depends on what I’m doing, but generally I use python to set a cap speed, and then use applyImpulse to accelerate and decelerate the character. This got a lot easier now that you can set a maximum speed with a single function call.

I’m currently avoiding servo like the plague, partly because it’s still really buggy but mostly because you get so little control over them. Pretty much the same reason I use python instead of logic wherever possible.