cont = bge.logic.getCurrentController()
own = cont.owner
col = cont.sensors['GroundCOL']
speed = own.getLinearVelocity()
#own['Health'] = (5) only for testing if the script works
if speed < -50 and col.positive:
own['Health'] -= (2)
Now, it removes health as needed, but not from falling. getLinearVelocity always returns 0, as I have checked in the console.
I see (this is my perspective on it) the character physics type to be in the same caste of objects as the mouse-look actuator. Quick-n-easy rigs for setting up rough prototypes with minimal viability. Not functional enough to hold their own on anything beyond that, but something you can plug in right away to have something to work with until you have something to replace it with. The mouselook actuator is great for what it’s good for: setting up mouselook in a couple seconds without having to touch a script. But that’s about it.
The problem with the character physics type is, unfortunately, that it’s straight-up broken. Fortunately though, there isn’t much that the character type does that dynamic/rigid body doesn’t also do. Step height is probably the only thing that wouldn’t be straight-forward.
Another thing: Just because your character is ‘moving’ doesn’t always mean that they have velocity. If you’re using the simple motion types (Loc/Rot), you are translating the object from point A to point B. If I jump into my teleporter and teleport myself 2mm to the left, how fast am I travelling? 0
If you want to be able to measure velocity on an object, you have to give it physics-based motion – Force, or setting the Velocity directly. And for physics-based motion to work, you need a physics-enabled object (dynamic/rigid-body).
Yep, I think it definitely needed .copy(), to be on the safe side
And to read velocity from any object physics type, you could parent another rigid/dynamic objects to ones that don’t have it eg. I parented a cube(invisible/ghost rigid body) to my camera(no collision physics type), so that I could get those readings even when I don’t have a body/player
btw dynamic object have angular velocity too, just aren’t used to simulate the physics