use of org.terasology.logic.characters.CharacterMovementComponent in project Terasology by MovingBlocks.
the class BulletPhysics method createCharacterCollider.
/**
* Creates a Collider for the given entity based on the LocationComponent
* and CharacterMovementComponent.
* All collision flags are set right for a character movement component.
*
* @param owner the entity to create the collider for.
* @return
*/
private CharacterCollider createCharacterCollider(EntityRef owner) {
LocationComponent locComp = owner.getComponent(LocationComponent.class);
CharacterMovementComponent movementComp = owner.getComponent(CharacterMovementComponent.class);
if (locComp == null || movementComp == null) {
throw new IllegalArgumentException("Expected an entity with a Location component and CharacterMovementComponent.");
}
Vector3f pos = VecMath.to(locComp.getWorldPosition());
final float worldScale = locComp.getWorldScale();
final float height = (movementComp.height - 2 * movementComp.radius) * worldScale;
final float width = movementComp.radius * worldScale;
ConvexShape shape = new CapsuleShape(width, height);
shape.setMargin(0.1f);
return createCustomCollider(pos, shape, movementComp.collisionGroup.getFlag(), combineGroups(movementComp.collidesWith), CollisionFlags.CHARACTER_OBJECT, owner);
}
use of org.terasology.logic.characters.CharacterMovementComponent in project Terasology by MovingBlocks.
the class MovementDebugCommands method stepHeight.
@Command(shortDescription = "Sets the height the player can step up", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String stepHeight(@Sender EntityRef client, @CommandParam("height") float amount) {
ClientComponent clientComp = client.getComponent(ClientComponent.class);
CharacterMovementComponent move = clientComp.character.getComponent(CharacterMovementComponent.class);
if (move != null) {
float prevStepHeight = move.stepHeight;
move.stepHeight = amount;
clientComp.character.saveComponent(move);
return "Ground friction set to " + amount + " (was " + prevStepHeight + ")";
}
return "";
}
use of org.terasology.logic.characters.CharacterMovementComponent in project Terasology by MovingBlocks.
the class MovementDebugCommands method playerHeight.
@Command(shortDescription = "Sets the height of the player", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String playerHeight(@Sender EntityRef client, @CommandParam("height") float amount) {
try {
ClientComponent clientComp = client.getComponent(ClientComponent.class);
CharacterMovementComponent move = clientComp.character.getComponent(CharacterMovementComponent.class);
if (move != null) {
float prevHeight = move.height;
move.height = amount;
clientComp.character.saveComponent(move);
LocationComponent loc = client.getComponent(LocationComponent.class);
Vector3f currentPosition = loc.getWorldPosition();
clientComp.character.send(new CharacterTeleportEvent(new Vector3f(currentPosition.getX(), currentPosition.getY() + (amount - prevHeight) / 2, currentPosition.getZ())));
physics.removeCharacterCollider(clientComp.character);
physics.getCharacterCollider(clientComp.character);
return "Height of player set to " + amount + " (was " + prevHeight + ")";
}
return "";
} catch (NullPointerException e) {
e.printStackTrace();
return "";
}
}
use of org.terasology.logic.characters.CharacterMovementComponent in project Terasology by MovingBlocks.
the class MovementDebugCommands method setJumpSpeed.
@Command(shortDescription = "Set jump speed", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String setJumpSpeed(@Sender EntityRef client, @CommandParam("amount") float amount) {
ClientComponent clientComp = client.getComponent(ClientComponent.class);
CharacterMovementComponent move = clientComp.character.getComponent(CharacterMovementComponent.class);
if (move != null) {
float oldSpeed = move.jumpSpeed;
move.jumpSpeed = amount;
clientComp.character.saveComponent(move);
return "Jump speed set to " + amount + " (was " + oldSpeed + ")";
}
return "";
}
use of org.terasology.logic.characters.CharacterMovementComponent in project Terasology by MovingBlocks.
the class MovementDebugCommands method showMovement.
@Command(shortDescription = "Show your Movement stats", requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String showMovement(@Sender EntityRef client) {
ClientComponent clientComp = client.getComponent(ClientComponent.class);
CharacterMovementComponent move = clientComp.character.getComponent(CharacterMovementComponent.class);
if (move != null) {
return "Your SpeedMultiplier:" + move.speedMultiplier + " JumpSpeed:" + move.jumpSpeed + " SlopeFactor:" + move.slopeFactor + " RunFactor:" + move.runFactor;
}
return "You're dead I guess.";
}
Aggregations