BGE Action Actuator module not working? (It doesn't play the action specified)

Okay, I am trying to set up a simple vehicle game prototype using animation as a steering method. However, while testing it out, the Python action actuator module doesn’t seem to be working. It seems to ignore all of the variables that I have set in, including the current frame. Here is the blend file for your convenience: Land Vehicle.blend (147 KB)

So how can I play the animation using only Python? I don’t really get why no animations are playing.

This could have a couple of reasons since there’s a lot wrong with your setup. You shouldn’t use an armature to turn the wheels. Armature deformation works by parenting the mesh object to the armature or to the bones of an armature. Either way, the mesh object will become static. You have to go for another strategy which doesn’t involve armatures.

You could play actions on the wheels, but since you’re using Python why not write a script for that instead. Or even better, use the Vehicle Wrapper.

Both action actuator and direct python playing do work. In python:


object.playAction(name, start_frame, end_frame, layer=0, priority=0, blendin=0, play_mode=KX_ACTION_MODE_PLAY,layer_weight=0.0, ipo_flags=0, speed=1.0)

But I suggest you read the above post about your setup. You won’t be able to spin the wheels if you turn them this way and the armature turning the wheels will only be cosmetic and not affect how the car moves.

Also if some other people experience actions not playing on their rigged characters, always remember to check that the armature modifier is last in the modifier stack of the object.

Maybe the parenting of the wheels is blocking something. Use constraints. Don’t use direct parenting . Here is my version of it. This almost drives like a tank.

Attachments

Land Vehicle 001.blend (236 KB)

Thanks. I currently do not know how to use the Vehicle Wrapper. It seems as if I would need to do some hacking before making a wheel spin. Anyways, thanks for this useful info!

I have no idea about the vehicle wrapper. This one could be used as a tank but how do we make one that moves like those cars in GTA4 for example ?

Attachments

Land Vehicle 002.blend (373 KB)

I’ve updated an example of the vehicle wrapper I was working on. Maybe this can help too.

Edit: deleted some needless code
Edit2: corrected angle limits (where 380 instead of 360) and keyboard events

Attachments

Car_Steeringwheel_02.blend (256 KB)

Your last blend file is crashing Blender as soon as press P to play. If i disconnect the script i can press P and it’s not crashing so I’m guessing there is something wrong with the “Car.translate” function somewhere. Any idea how many of those scripts can Blender handle at once ?

Attachments

Land Vehicle 003.blend (779 KB)

Your last blend file is crashing Blender as soon as press P to play. If i disconnect the script i can press P and it’s not crashing so I’m guessing there is something wrong with the “Car.translate” function somewhere. Any idea how many of those scripts can Blender handle at once ?[/QUOTE]
That’s strange. What blender version are you using? Anyone else got the same problem?

I’m using the latest version available from SVN compiled from source code (Blender 2.68.5). At line 145 in Car.py you are trying to assign an instance of the class to a gameobject property. That’s not supposed to work in any Blender version , lol. Another problem is that your class definition is not accepting any inputs but you are passing your vehicle as an input , so that part is not going to work either.

Well, for me what blenderer2012 is trying to say in this quote:

At line 145 in Car.py you are trying to assign an instance of the class to a gameobject property. That’s not supposed to work in any Blender version , lol.

is that it is extremely tricky to assign anything with the Vehicle Wrapper. For example, the following code would result in a sub-classing error:


from bge.types import *
from bge.logic import *

scene = getCurrentScene()

def main():car = KX_VehicleWrapper(scene.objects["Car"])
print(car)



So far all I know is that a GameObject is a Subclass of PyObjectPlus, but it is not recognized by the KX_VehicleWrapper module for some reason. The Blender version that I am currently using is 2.67.

Thanks for your reply, ReubenUnicruz. So is Blender also crashing with you when you play the file? I’m playing with 2.66a and it’s not crashing here.

Also, you are mentioning KX_GameObject not being recognized by the KX_VehicleWrapper, but how come then that I’m not having any problems?

Could anyone please confirm if the script is causing a crash or not?

Edit: To moderator: since this is getting off-topic could you split this up into a separate thread, named: “KX_VehicleWrapper crash”, beginning from post #9. Thank you.

Weird , it seems to work with version 60254. There must be something wrong with one that i compiled from svn. That one says 2.68.5 but release number shows as ‘unknown’.

bge.types.KX_VehicleWrapper(PyObjectPlus) inherits from PyObjectPlus, not KX_GameObject.
It wouldn’t be hard to define your own wrapper that can accept a car body and determine the wheels and other information automatically.
Inheritance is one-way; from parent to child. It is not reciprocal.

Okay, that’s a relief. Thanks for double-checking. I was worried there for a bit. I find this method very useful for the vehicle wrapper. And I wouldn’t want to post bad coding examples on the forum. Hope it can be helpful to others too.

I’m not sure what you mean. But I would be interested in finding a way to be able to remove the wheels. I’m gonna look into that right away. (since there have been problems with this, I recall).