Animation in BGE

Hey. I’ve finally got a good concept after a few tries (like the minigame jELLY). But I’m having trouble getting the animations in this game to work correctly. I’m pretty good with python and am a super fast learner so if it is new python I can get it down. Here is the .blend. If anyone has a solution to animations and movement or even advice please post.

RVB.blend

What exactly are you having trouble with? The animations are playing, and your character is moving…

Are you wondering about how to make the movement smoother and match the animation more? That’s just going to take simple tweaking… though I recommend you look into servo motion for better/smoother movements.

Just mess with it until it’s right!

-Sam

Yea, I meant it needs adjusting. Thanks. I’ll modify it and post it in the WIP section too. The animations don’t match the movement very often is what I’m needing to fix. Any advice on how to fix the movement and animation matching?

I advise you to write a short function that sets the animation speed, using a Property Action actuator. Then it becomes really easy and fast to adjust the speed of any animation. So if you need to adjust something to match the movement you just set some speed on your script, test it, try another number, test it again. etc… until it looks pretty.

Thanks, I’ll also try that. I have one more problem though. The character slides way to much. I think I can solve this with friction though. Not quite sure.

Sliding can most certainly be fixed with friction. To add friction (in case you don’t know) you can select the ground object, give it a material, then click on the “DYN” button in the material settings. Then you can mess with friction values on the material.

I’d still really recommend you use Servo motion instead of LinV. It’s a much more stable and predictable movement type.

-Sam

Thanks for that I didn’t know that. But now I have a problem. The material friction is applied after the game ticks of my motion actuator. So setting a high friction value decreases the speed of my character while walking. I looked up the API for something to disable the friction during the walk state but I didn’t find it.

Is there any way to use material friction to only be applied when I want it to?

This is exactly what Servo motion was made to help…

Servo motion lets you designate a certain velocity, and then you can specify the “max force” Blender can use to get that object to that velocity. So if you have a high amount of friction, Blender will apply enough force (up to the max force you specify) to get your object moving the appropriate speed. Then, when you aren’t trying to move, friction will work normally.

I usually use a max force of 50-100 for most of my objects, since it basically will get your object moving the velocity you want instantaneously. Try messing around with it!

-Sam

I just tried it with servo instead. But unfortunately the max/min force isn’t for external forces such as friction. Only for the force applied by the servo controller itself. I tried limiting force against movement direction to zero, but friction was still applied. Changing the material friction affects acceleration when using a servo control, but changing the force limit in the control didn’t affect it.

Even if I don’t set a force limit, the unlimited force done by servo cannot beat friction and there is still an acceleration. Unlimited force minus limited friction should results in irrelevant friction acceleration, no?

How much friction are you setting?

The most I’ve ever used is 2… and even that is probably too much. You’re setting the coefficient of friction… more info on this is here http://www.engineeringtoolbox.com/friction-coefficients-d_778.html.

When you say the “min/max isn’t for external forces like friction,” what do you mean? Servo control applies as much force as possible to get to the desired speed… if Friction is slowing your object, servo will use MORE force. If you’ve reached the max speed, servo puts in just enough force to keep your object at that speed. Yes, friction is still working on your object, but it doesn’t matter since Servo is putting in enough force in the opposite direction to cancel out the force of friction.

Because servo does use force (just like in the real world) objects are accelerated and decelerated. That’s just how it does (and should) work. Servo uses forces, so there will always be an acceleration, but with a little tweaking you can get it to be virtually unnoticeable.

Servo doesn’t calculate exactly how much force to start with, however… it just starts somewhere and increases force until it gets a good amount. This is why you see some differences in the two frictions… servo is starting out at the same point and then attempting to increase force to get to the desired speed. You can mess with the I and P settings to get a quicker starting time… I got relatively good results with doubling P for double the friction.

Regardless, servo results in much more realistic motion. Friction in the real world never gets “turned off” when we walk… we just apply enough force to keep us going. Servo will do the same thing, and with tweaking can easily suit your needs.

-Sam

Yes, I know this. I’ve applied friction to my grass material now and decided to keep the add velocity on simple motion. I don’t like how servo set’s my velocity instead of adding to it. It makes it so I can float in the air when I jump. I like air control, but i don’t want floating. I wish there was a max speed constraint in the constraints brick.

Servo doesn’t set velocity… but it will seem that way unless you click on the buttons for ALL of the axis, even the ones that you’re not using. If you’re only using X, then still click on Y and Z, but don’t put anything in their velocity/min/max forces.

LinV DOES set velocity, and if you use the “add” feature you’re going to get some unwanted side effects. Try tapping whatever button you use for movement… and the velocity will continuously be added to the velocity… meaning you can achieve huge speeds.

That solves that issue, and I’ve figured out how to make it run ONLY when it is on the ground. The friction I’ve set to the ground is also perfect and achieves the desired affect. Now I’m thinking about how to get it to turn around. My idea is an empty it tracks to that has three frames. Using an ipo actuator have it be right and left when the d or a keys are pressed. and for combat, I think I want another state for that. not sure yet. Thanks for the help.
I’m going camping for 10 days so I want be able to reply until then.