Character type .gravity is broken in 2.79?

https://docs.blender.org/api/2.79/bge.types.KX_CharacterWrapper.html?highlight=character%20wrapper

doesnt work anymore ???

import bge
cont = bge.logic.getCurrentController()
own = cont.owner
char=bge.constraints.getCharacter(own)
char.gravity = 60.0

but when

char.gravity = -60.0

it go upwards… , 0 makes it still

it’s cool, but how could i set the gravity back ?

1 Like

char.gravity = scene.gravity.copy() ?

i dont know, just guessing. but usually gravity is 9.8 m/s.

why do you need this? just use an apply force or something.

EDIT:
ok, so the gravity is NOT a single float. its a vector, like in scene.gravity.

http://shuvit.org/python_api/bge.types.KX_CharacterWrapper.html

my character has character physic type so all those applyforce and stuff doesnt work as they apply only on dynamic objects… even gravity scene has no impact on my character. It’s really different

EDIT : cool , let me check (even if when i print the initila value its still a float 29.399999618530273

ok, never mind. vanilla bge is float.

jeez, this is why i dont bother with the character wrapper. you are totally at the mercy of the bge.

so it’s really broken in 2.79 ? works with upbge ?

yes, but character physic type seems to do what i need … until now :slight_smile:

no idea, ive only used the character wrapper once, and it was someone elses project.

could be just setting zero messes it up?

EDIT:
this is probably the equivelent of a mass setting

Character physics aren’t all that good. You’re better off using dynamic or static and coding in behaviours yourself.

yes, but why did they made that character physic in the first place ?

edit : char.gravity is not completely dead. It reacts to pulse (+= a small float value) . I would like to understand how to set back its initial value

like any code, it assumes you are a competent person who can remember what they want to set it to, and what to set it back to.

theres no real “restore defaults” in coding. its all about design intent. what do you want it to be?

ofc i know how to restore a value. I just meant why it precisely doesnt works in this specific case

My guess would be the aim was to cover basic character physics. To get anything but the basic behaviours, you need to switch to something else.

i would recommend dynamic with 0 damping and use linear velocity to move the character.

strange, i have it working now

yes, i would probably switch to dynamic for my character. But later :slight_smile:

ive been considering making a standalone script of my character physics. ive put so much work into the stability, i dont want it to be exclusive or niche.

not to get off topic…

no, this will be excellent to have because … this character wrapper really acts strange. char.gravity doesnt seems to directly = Max jump speed.

thats because its probably not that simple. gravity is a force, more of a scalar than a hard limit.

higher will be a short fast jump, and lower would be floaty. max speed is likely a hard cap, stopping the natural flow of simulated physics.

ok , to summarize “Fall speed max” <> .gravity. I though that .gravity was a proxy for “fall speed max” but no.

  • “Jump force” >= 0 and “Fall speed max” > 0 ; object will fall as long as .gravity > 0
  • “Jump force” > 0 and “Fall speed max” = 0 ; object will goes up as soon as .gravity < 0
  • “Jump force” = 0 and “Fall speed max” = 0 ; object doesn’t react to .gravity
  • Set .gravity to 0 and you will simply preserve the current speed (up or down) … just like in space (look the movie with Sandra Bullock Gravity , if you ignore physics law in space)

So you must play with the .gravity to weight with momentum those 2 opposite forces

EDIT : There’s no balance trick : Set the object with Jump Force = 2 and Fall Speed Max = 500 , as soon as the gravity is setted negative, your object will slow down and will ends going up after reducing its falling speed to 0 (so an collision will help for that)

yeah, gravity is like a mass. zero G aka space if zero.

gravity is a constant acceleration in a set direction. physics 101. fall speed max sounds like simulating air friction to hack terminal velocity.

does fall speed at zero disable it?