uClass ANimCharacter of ACharacter:
uprops(EditAnywhere, BlueprintReadOnly, DefaultComponent, Category = Camera): # DefaultComponent ensures the component is created by the constructor
cameraBoom : USpringArmComponentPtr
uprops(EditAnywhere, BlueprintReadOnly, DefaultComponent, Attach=(cameraBoom, SpringEndpoint), Category = Camera):
followCamera : UCameraComponentPtr
uprops(EditAnywhere, BlueprintReadOnly, Category = Input):
defaultMappingContext : UInputMappingContextPtr
(jumpAction, moveAction, lookAction) : UInputActionPtr
defaults: # default values for properties on the cdo
capsuleComponent.capsuleRadius = 40
capsuleComponent.capsuleHalfHeight = 96
bUseControllerRotationYaw = false
characterMovement.jumpZVelocity = 700
characterMovement.airControl = 0.35
characterMovement.maxWalkSpeed = 500
characterMovement.minAnalogWalkSpeed = 20
characterMovement.brakingDecelerationWalking = 2000
characterMovement.bOrientRotationToMovement = true
cameraBoom.targetArmLength = 400
cameraBoom.busePawnControlRotation = true
followCamera.bUsePawnControlRotation = true
proc setupPlayerInputComponent(playerInputComponent : UInputComponentPtr) = #Notice here we are overriding a native cpp virtual func. You can call `super` self.super(playerInputComponent) or super(self, playerInputComponent)
let pc = ueCast[APlayerController](self.getController())
let inputComponent = ueCast[UEnhancedInputComponent](playerInputComponent)
let subsystem = getSubsystem[UEnhancedInputLocalPlayerSubsystem](pc).get()
subsystem.addMappingContext(self.defaultMappingContext, 0)
inputComponent.bindAction(self.jumpAction, ETriggerEvent.Triggered, self, n"jump")
inputComponent.bindAction(self.jumpAction, ETriggerEvent.Completed, self, n"stopJumping")
inputComponent.bindAction(self.moveAction, ETriggerEvent.Triggered, self, n"move")
inputComponent.bindAction(self.lookAction, ETriggerEvent.Triggered, self, n"look")
proc move(value: FInputActionValue) =
movementVector = value.axis2D()
rot = self.getControlRotation()
rightDir = FRotator(roll: rot.roll, yaw: rot.yaw).getRightVector()
forwardDir = FRotator(yaw: rot.yaw).getForwardVector()
self.addMovementInput(rightDir, movementVector.x, false)
self.addMovementInput(forwardDir, movementVector.y, false)
proc look(value: FInputActionValue) =
let lookAxis = value.axis2D()
self.addControllerYawInput(lookAxis.x)
self.addControllerPitchInput(lookAxis.y)
uClass ANimGameMode of AGameModeBase:
proc constructor(init:FObjectInitializer) = #Similar to default but allows you to write full nim code
let classFinder = makeClassFinder[ACharacter]("/Game/ThirdPerson/Blueprints/BP_ThirdPersonCharacter")
self.defaultPawnClass = classFinder.class