character¶
- class Character(obj)¶
Bases: bge.KX_GameObject
A character wrapper
Parameters: obj – The KX_GameObject to mutate Warning
You should never use this class’s constructor, always use the spawn() method to create a character.
- MAX_HP = 10¶
Maximum HP for the character
- MAX_SPEED = 0.1¶
Maximum speed of the character
- MAX_AIR_SPEED = 0.07500000000000001¶
Maximum speed while airborne
- ACCELERATION = 0.01¶
How much to accelerate the character while moving
- DECELERATION = 0.1¶
How much to deccelerate the character while not moving
- FRICTION = 0.01¶
Amount of friction applied to the character while moving and stopping
- RUN_MULTIPLIER = 2.0¶
How many times faster the character (and their move animations) are while running
- GRAVITY = 49.0¶
Starting gravity value for the Bullet character controller
- MESH = ''¶
The name of the blendfile and object to use for spawning an instance of the character
- ANIMATIONS = {}¶
Mapping of animation names to their actions. Each item is a dictionary of keyword arguments to KX_GameObject.playAction(), and each item is played in its own layer.
The following animation names are currently recognized by the default Character class:
- idle
- Idle Animation (the character isn’t moving or airborne)
- move
- The character is moving on the ground (i.e., not airborne)
- jump
- The character is airborne
- dead
- The character is dead
- class Character.MoveAnimState(character)¶
Bases: scripts.framework.animations.AnimationState
- update()¶
- class Character.JumpAnimState(character)¶
Bases: scripts.framework.animations.AnimationState
- update()¶
- class Character.DeadAnimState(character)¶
Bases: scripts.framework.animations.AnimationState
- update()¶
- Character.is_dead¶
True if the character is dead
- Character.gravity¶
The current gravity value used for Bullet’s character controller
- Character.airborne¶
True if the character is in the air
- Character.armature¶
The object to use for playing animations
- classmethod Character.spawn(position=None, orientation=None)¶
Spawns an instance of the character
Parameters: - position – The world position of the new instance
- orientation – The world orientation of the new instance
Return type: The new character instance
- Character.free()¶
Frees the blendfile used for the character
- Character.rotate(rotation)¶
Rotate the character about its z axis
Parameters: rotation – Amount of rotation in radians
- Character.update()¶
Update method which should be called every frame to update this character
- Character.move(direction)¶
Moves the player horizontally
Parameters: direction – A direction vector for the movement
- Character.jump()¶
Makes the character jump