I want to have a cube where on tapping the up arrow, the cube rolls forwards and stays put in the new position it rolled to (will then add other directions later). I figured the best way to do this would be to have an action made of the roll because then I could adapt the animation to any style of movement (jump, lumber etc).
But how do I go about making the simple action work with movement? Until now I’ve only played with basic physics engine dynamics in the games engine, not actions. I thought they would play nicer than they do.
Currently, I am adding two actuators; one for the roll animation, and another movement which was to be a full step, though the actuators seem to be interfering with each other.
:o Isn’t this awful? => cube_roll.blend (75.7 KB)
Please take a look at my file and let me know of more efficient ways of doing it.
the last broken frame is for the “not very intelligent” speed of 0.4
so you make a feyframe at 10 and 11 , but in the game engine is renderized also “some frame” in the middle between 10 and 11.
a workaround can be choose a no-autosnap(in the animation windows) , and move the key frame 11 to more or less 10.1.
i checked if there some good news in 2.63 , but not
this here the frame rendered
Thanks for your reply MarcoIT. Yes, the bad end keyframe is visibly corrected by moving frame 11 to 10.01. Thanks.
There’s still a major flaw in my workflow though. Even with the keyframe fix, if you tap UP arrow rapidly, the animation kicks in at odd times and the cube is soon moving diagonally uphill. Also, with the simple motion Actuator moving the cube slightly forward, it does not end up being exactly 2 Blender Units to the next square. In a large playing field (e.g. a chessboard) the cube would eventually be stepping on half squares.
If I had only the simple motion actuator, set as Y=-2, then the cube shunts to the correct position. This is without the roll though, so not what I want.
I’m thinking that my problem could be solved if the animation were truly read as local coordinates. Currently it seems to be global which means without the second actuator it always restarts the cube from the same place.
I’d have a go at using python, but not sure how to call the action animation from a script… but can’t this be done with logic blocks?
I figure that if I don’t want to have the cube sloping uphill, then parent/child or use of an armature rig can be used to ensure the base itself is never actually rotated. The base moves but only staying “flat”, whereas this has a child bone to which the cube is attached, and this second bone is what controls the rotation.
That sounds harder than what it is.
Please take a look at the file to see: cube_roll_bones.blend (81.3 KB)
It’s better than it was but there are still problems.
I can’t think of a better way than to set it up like this:
- two objects: “Cube” (parent) has Motion Actuators, “Actor” (child) has Action Actuators
- “Timer” Property and expressions (for the Key Sensors) to make sure no Actions are overlapping and every Action is played entirely
- “Roll” Actions in every direction
Of course it’s cleaner to use python, instead of using expressions and an extra Property Actuator. I’ve made two blends:
cube_roll_python.blend (79.5 KB)cube_roll_expressions.blend (78.4 KB)
Hey - those are pretty neat examples, thanks.
I’ve had a play with them and will need to study them a bit more. Not afraid of Python (I’ve passed certain programming courses in Python) though where Blender calls things like executing actions is a bit foreign so it’s valuable to have your examples. Thanks.
Still studying your solution, though I’ll mark the thread as closed as I think you’ve nailed it.
It was a pleasure and I learned a lot from it myself. I made some more improvements though. Each roll the Cube’s rotation was reset to the initial pose. So texturing the Cube’s faces with different images was out of the picture.
I modified some Actions to be able to combine them with the Add option in the Action Actuators. Still some miniscule shifting during gameplay occurred due to the Add function. So I fixed this with rounding the position and orientation of the Actor on every Axis. I think this result is better than the previous one:
cube_roll_python2.blend (86.1 KB)
That’s very cool. I’d tried utilising the Add feature but with the methods I was using before it always reset as though everything was absolute global. Another one to examine.
amazing! is perfect!
(I had thinked the only way was to make a armature! )
Have you guys heard of colorcube? It’s kind of off topic but it uses this, too.
This is a Blender Game, by the way.
Not off topic. I’d had a game something like that in mind but because I couldn’t remember anything specific about it other than that it was a platform game with a rolling cube I decided not to mention it because it would turn the thread into “guess my game” rather than problem solving. I was trying to find where the game was on my hard drive because I thought having a peek inside would give a clue but my file search came out blank. I think it may have been a finalist in a games making competition where only logic blocks were allowed… like I say my memory of it was a bit vague. It was toon-shader style and may have been an early version of what’s in your video.