1
$\begingroup$

Using the built-in Character physics, one of the features is Jumping by using the Character Motion "Jump" actuator or using the bge.constraints.getCharacter(obj).jump() function in Python.

when I attempt to print out the character's velocity with print(obj.getLinearVelocity(True)), and also tried False, the console just repeats "Vector (0.0000, 0.000, 0.000)" on each frame as I jump around the stage with my character.

For scripting purposes, I really would like to have an accurate statistic of my character's velocity. Is there a hidden velocity stat that is associated with the Character Physics feature?

In the API, it's missing a lot of info on this subject. https://www.blender.org/api/blender_python_api_2_77_release/bge.types.KX_CharacterWrapper.html

$\endgroup$
2
$\begingroup$

Problem

The "Character" Physics Type does not imply that this object uses the build-in Physics engine. Regarding the Physics engine this kind of object is still a static object.

Therefore you can't apply velocities or forces, nor can you read them. The object teleports within the scene by its own, rather than it is moving in terms of the physics engine.

Solution

Physics engine

Either you use a real (moving) physics type (rigid body, soft body, dynamic),

Character physics

or you record the position at each frame. This way you can calculate the traveled distance from frame to frame via Python. It is simply the difference between the current's frame position and the position of the previous frame.

Remarks

In my eyes

  • Rigid Body, Soft Body, Dynamic and Static are real physics types.
  • Sensor and No Collision are attributes (or attribute sets) of physics types
  • Character, Navigation Mesh and Occluder have nothing to do with physics and should not be at this place. These setting should be at object level not at physics level.
$\endgroup$
  • $\begingroup$ Thank you, this has been enlightening for me. How do you make a record of where an Object was during previous frames? $\endgroup$ – revengeofthemadmadman Aug 6 '16 at 4:06
  • $\begingroup$ I suggest to ask a new question regarding the new topic. (Basically you write the current position into a property, so you can read it within the next frame). $\endgroup$ – Monster Aug 8 '16 at 5:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.