8 directional animation?

Hi blender forum,

I’ve created and rigged a character and gave it 9 keyframes, one for every 8 directions, and one neutral pose.
I am trying to give it arrow key controls, where up and left together would be a diagonal, while up and left also work individually. The character should always return to neutral when nothing is held, and should hold whatever pose when a key is pressed until the key is released or changed.

I’ve been trying to do this with logic bricks, but I quickly ended up with a tangled mess that doesn’t work correctly. How do create a movement system that resolves the issues in a way that is buttonmash-proof? As in resolving all cases of simultaneous button presses?

I’ve never used python before.

You don’t need to try Python just for a simple animation implementation, just try to be more specific in your logic and you will reach the desired results. Example, instead of:


Try to clearly specify the conditions. You may press UP, but in this example, if you press any other sensor, you will mess the result. You may try to use the Action Actuator ‘Priority’ to work around, but it soon gets confusing and leads to unexpected results. Instead, try to use:


And for the Idle animation just add an Always sensor and all the other keys (with NOT in its conditions too). A clear definition of logic is much more efficient than working around. I hope it helps. :wink:

EDIT: If the logic gets too big to manage, remember to use states to organize your bricks.

hi shadowdancerC96

I test this logic bricks control for 8 rotation angles.

The or controller detect one key from Up Down Right Left

The nor onnctroller detect no key from Up Down Right Left

the two keys action (as Up and Left) go on AND controllers

One key actions goes on EXPR controllers.

Attachments

rotation_logick_bricks.blend (476 KB)

I like your solution, but at this point if you want to write basic EXPR you’d be better off with a bit of Python :slight_smile:
(just the minimal)

Just in case, you can have a Python controller set up to run a script “yourScript.py”, where you plug all your sensors on, and all your animations on:


import bge

controller = bge.logic.getCurrentController()

# to get a sensor you can write:
sensorA = controller.sensors.get("nameOfSensorBrick")

# and you can fetch the actuators:
actuatorA = controller.actuators.get("nameOfActuatorBrick")

# then you can write stuff like
if sensorA.positive:
    controller.activate(actuatorA)
else:
    controller.deactivate(actuatorA)

Hope you will find a way to express your logic :slight_smile:

Thanks everyone for all the replies. I think your solution is the most applicable to what I already have and should make it much easier to keep my logic bricks neat and tidy. Thank you.

I everone

here is a python script version.

I don’t use frame (but this is possible)

Attachments

rotation_script.blend (92.3 KB)

Are you looking for something like this? it uses vectors to get a direction.
https://blenderartists.org/forum/showthread.php?408933-Third-person-TERA-style-movement-system (python based)