Ok so I decided to try and learn python and from the tutorial to learn the basics of movement I cant get my version or the (this is how it should be version from owner) to work by chance does anyone see what I am doing wrong?
cont = GameLogic.getCurrentController()
own = cont.getOwner()
Sensors: forward = cont.getSensor("Up") backward = cont.GetSensor("Down") turnleft = cont.getSensor("Left") turnright = cont.getSensor("Right")
Actuators Motion = cont.getActuator("Motion")
Process speed = 5 rspeed = 0.02 walk = 0 turn = 0 if forward.isPositive(): walk = speed if backward.isPositive(): walk = -speed if turnleft.isPositive(): turn = rspeed if turnright.isPositive(): turn = -rspeed motion.setlinearVelocity(0, walk, 0, 1) Motion.setDRot(0, 0, turn, 1) GameLogic.addActiveActuator(motion, 1)
Does the console print any errors? If you’re using 2.49, use controller.sensors[‘Sensorname’] instead of controller.getSensor(‘Sensorname’). Use the same thing for actuators, too (replace ‘sensor’ with ‘actuator’, obviously). Your actuator is named ‘Motion’, but your setting values use ‘motion’ - Most computer languages, including Python, is case-sensitive, so setdloc is not the same as the function name setDLoc, and so that would raise an error. Finally, you’re using GameLogic.addActiveActuator(actuatorname); you should use cont.activate(actuatorname). Here’s an example. It won’t work; see if you can figure out why. It’s just one problem.
EDIT: Finally, while working on your game, check the console, even if there isn’t really any errors or problems, because you may be using deprecated (old) functions for which there are better methods to access them. Keep working with Python; you’ll be an advanced BGE user, able to make exploding super monster heat-seeking rabbits in no time. LOL
Learning Python isn’t actually too hard. It’s quite easy to just use the part that you need, and not really use anything else. Like I said before, use the console a lot. Without that, you could be completely in the dark. Also, use:
print (dir(function, variable, or module name here)) to print a directory of what that object has and can do. For example, when I used that on an object’s position (which is an object of the Vector class, and so is a vector), I saw a lot of ‘xyz, xzy, yxz, etc.’ variables in the console. I figured out that you can access the object’s individual values through those variables. So, rather than using the old way of setting positions like:
to achieve the same effect, and it appears far more visually pleasing. Finally, download the version of Python that Blender uses, or just download the help file for that version and go through the tutorial in that; it’s not very long and really helps to grasp the basics of variables, functions, lists, dictionaries, etc.
I was able to learn enough to add the rest of the movement buttons front back so on im also going to work on trying a jump. I used blender 2.49 I dont think I can learn a new layout and crap plus learn script so I will stay for now I think im caught in between the way you showed me and another way thats something like this getactuator() I like your way better but I havent see to much go off for your way.
If I have troubles in future by chance could I ask for your help =) one me favorite blender users atm XD