Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions Source/S05_TestingGrounds.Target.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ public S05_TestingGroundsTarget(TargetInfo Target)
Type = TargetType.Game;
}

//
// TargetRules interface.
//

/**
* TargetRules interface.
*/
public override void SetupBinaries(
TargetInfo Target,
ref List<UEBuildBinaryConfiguration> OutBuildBinaryConfigurations,
Expand Down
26 changes: 14 additions & 12 deletions Source/S05_TestingGrounds/Player/FirstPersonCharacter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ AFirstPersonCharacter::AFirstPersonCharacter()
// Set size for collision capsule
GetCapsuleComponent()->InitCapsuleSize(55.f, 96.0f);

// set our turn rates for input
// Set our turn rates for input
BaseTurnRate = 45.f;
BaseLookUpRate = 45.f;

Expand All @@ -37,8 +37,9 @@ AFirstPersonCharacter::AFirstPersonCharacter()
// Default offset from the character location for projectiles to spawn
GunOffset = FVector(100.0f, 30.0f, 10.0f);

// Note: The ProjectileClass and the skeletal mesh/anim blueprints for Mesh1P are set in the
// derived blueprint asset named MyCharacter (to avoid direct content references in C++)
/* Note: The ProjectileClass and the skeletal mesh/anim blueprints for Mesh1P are set in the
derived blueprint asset named MyCharacter (to avoid direct content references in C++)
*/
}

void AFirstPersonCharacter::BeginPlay()
Expand All @@ -64,19 +65,20 @@ void AFirstPersonCharacter::BeginPlay()

void AFirstPersonCharacter::SetupPlayerInputComponent(class UInputComponent* InputComponent)
{
// set up gameplay key bindings
// Set up gameplay key bindings
check(InputComponent);

InputComponent->BindAction("Jump", IE_Pressed, this, &ACharacter::Jump);
InputComponent->BindAction("Jump", IE_Released, this, &ACharacter::StopJumping);

//InputComponent->BindTouch(EInputEvent::IE_Pressed, this, &AFirstPersonCharacter::TouchStarted);
// InputComponent->BindTouch(EInputEvent::IE_Pressed, this, &AFirstPersonCharacter::TouchStarted);
InputComponent->BindAxis("MoveForward", this, &AFirstPersonCharacter::MoveForward);
InputComponent->BindAxis("MoveRight", this, &AFirstPersonCharacter::MoveRight);

// We have 2 versions of the rotation bindings to handle different kinds of devices differently
// "turn" handles devices that provide an absolute delta, such as a mouse.
// "turnrate" is for devices that we choose to treat as a rate of change, such as an analog joystick
/* We have 2 versions of the rotation bindings to handle different kinds of devices differently
"turn" handles devices that provide an absolute delta, such as a mouse.
"turnrate" is for devices that we choose to treat as a rate of change, such as an analog joystick
*/
InputComponent->BindAxis("Turn", this, &APawn::AddControllerYawInput);
InputComponent->BindAxis("TurnRate", this, &AFirstPersonCharacter::TurnAtRate);
InputComponent->BindAxis("LookUp", this, &APawn::AddControllerPitchInput);
Expand Down Expand Up @@ -149,7 +151,7 @@ void AFirstPersonCharacter::MoveForward(float Value)
{
if (Value != 0.0f)
{
// add movement in that direction
// Add movement in that direction
AddMovementInput(GetActorForwardVector(), Value);
}
}
Expand All @@ -158,20 +160,20 @@ void AFirstPersonCharacter::MoveRight(float Value)
{
if (Value != 0.0f)
{
// add movement in that direction
// Add movement in that direction
AddMovementInput(GetActorRightVector(), Value);
}
}

void AFirstPersonCharacter::TurnAtRate(float Rate)
{
// calculate delta for this frame from the rate information
// Calculate delta for this frame from the rate information
AddControllerYawInput(Rate * BaseTurnRate * GetWorld()->GetDeltaSeconds());
}

void AFirstPersonCharacter::LookUpAtRate(float Rate)
{
// calculate delta for this frame from the rate information
// Calculate delta for this frame from the rate information
AddControllerPitchInput(Rate * BaseLookUpRate * GetWorld()->GetDeltaSeconds());
}

Expand Down
4 changes: 2 additions & 2 deletions Source/S05_TestingGrounds/Player/FirstPersonCharacter.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ class AFirstPersonCharacter : public ACharacter
bool EnableTouchscreenMovement(UInputComponent* InputComponent);

public:
/** Returns Mesh1P subobject **/
/** Returns Mesh1P subobject */
FORCEINLINE class USkeletalMeshComponent* GetMesh1P() const { return Mesh1P; }
/** Returns FirstPersonCameraComponent subobject **/
/** Returns FirstPersonCameraComponent subobject */
FORCEINLINE class UCameraComponent* GetFirstPersonCameraComponent() const { return FirstPersonCameraComponent; }

};
Expand Down
4 changes: 2 additions & 2 deletions Source/S05_TestingGrounds/S05_TestingGroundsGameMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
AS05_TestingGroundsGameMode::AS05_TestingGroundsGameMode()
: Super()
{
// set default pawn class to our Blueprinted character
// Set default pawn class to our Blueprinted character
static ConstructorHelpers::FClassFinder<APawn> PlayerPawnClassFinder(TEXT("/Game/Dynamic/Player/Behaviour/FirstPersonCharacter"));
DefaultPawnClass = PlayerPawnClassFinder.Class;

// use our custom HUD class
// Use our custom HUD class
HUDClass = AS05_TestingGroundsHUD::StaticClass();
}
6 changes: 3 additions & 3 deletions Source/S05_TestingGrounds/S05_TestingGroundsHUD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ void AS05_TestingGroundsHUD::DrawHUD()

// Draw very simple crosshair

// find center of the Canvas
// Find center of the Canvas
const FVector2D Center(Canvas->ClipX * 0.5f, Canvas->ClipY * 0.5f);

// offset by half the texture's dimensions so that the center of the texture aligns with the center of the Canvas
// Offset by half the texture's dimensions so that the center of the texture aligns with the center of the Canvas
const FVector2D CrosshairDrawPosition( (Center.X),
(Center.Y));

// draw the crosshair
// Draw the crosshair
FCanvasTileItem TileItem( CrosshairDrawPosition, CrosshairTex->Resource, FLinearColor::White);
TileItem.BlendMode = SE_BLEND_Translucent;
Canvas->DrawItem( TileItem );
Expand Down
4 changes: 2 additions & 2 deletions Source/S05_TestingGrounds/Weapons/BallProjectile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ABallProjectile::ABallProjectile()
CollisionComp = CreateDefaultSubobject<USphereComponent>(TEXT("SphereComp"));
CollisionComp->InitSphereRadius(5.0f);
CollisionComp->BodyInstance.SetCollisionProfileName("Projectile");
CollisionComp->OnComponentHit.AddDynamic(this, &ABallProjectile::OnHit); // set up a notification for when this component hits something blocking
CollisionComp->OnComponentHit.AddDynamic(this, &ABallProjectile::OnHit); // Set up a notification for when this component hits something blocking

// Players can't walk on it
CollisionComp->SetWalkableSlopeOverride(FWalkableSlopeOverride(WalkableSlope_Unwalkable, 0.f));
Expand Down Expand Up @@ -40,4 +40,4 @@ void ABallProjectile::OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UP

Destroy();
}
}
}
6 changes: 3 additions & 3 deletions Source/S05_TestingGrounds/Weapons/BallProjectile.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ class ABallProjectile : public AActor
public:
ABallProjectile();

/** called when projectile hits something */
/** Called when projectile hits something */
UFUNCTION()
void OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit);

/** Returns CollisionComp subobject **/
/** Returns CollisionComp subobject */
FORCEINLINE class USphereComponent* GetCollisionComp() const { return CollisionComp; }
/** Returns ProjectileMovement subobject **/
/** Returns ProjectileMovement subobject */
FORCEINLINE class UProjectileMovementComponent* GetProjectileMovement() const { return ProjectileMovement; }
};

29 changes: 15 additions & 14 deletions Source/S05_TestingGrounds/Weapons/Gun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,29 @@ void AGun::Tick( float DeltaTime )

void AGun::OnFire()
{
// try and fire a projectile
if (ProjectileClass != NULL)
// Try and fire a projectile
if (ProjectileClass == NULL)
{
const FRotator SpawnRotation = FP_MuzzleLocation->GetComponentRotation();
// MuzzleOffset is in camera space, so transform it to world space before offsetting from the character location to find the final muzzle position
const FVector SpawnLocation = FP_MuzzleLocation->GetComponentLocation();
return;
}
const FRotator SpawnRotation = FP_MuzzleLocation->GetComponentRotation();
// MuzzleOffset is in camera space, so transform it to world space before offsetting from the character location to find the final muzzle position
const FVector SpawnLocation = FP_MuzzleLocation->GetComponentLocation();

UWorld* const World = GetWorld();
if (World != NULL)
{
// spawn the projectile at the muzzle
World->SpawnActor<ABallProjectile>(ProjectileClass, SpawnLocation, SpawnRotation);
}
UWorld* const World = GetWorld();
if (World != NULL)
{
// Spawn the projectile at the muzzle
World->SpawnActor<ABallProjectile>(ProjectileClass, SpawnLocation, SpawnRotation);
}

// try and play the sound if specified
// Try and play the sound if specified
if (FireSound != NULL)
{
UGameplayStatics::PlaySoundAtLocation(this, FireSound, GetActorLocation());
}

// try and play a firing animation if specified
// Try and play a firing animation if specified
if (FireAnimation != NULL)
{
// Get the animation object for the arms mesh
Expand All @@ -70,4 +71,4 @@ void AGun::OnFire()
}
}

}
}
7 changes: 3 additions & 4 deletions Source/S05_TestingGroundsEditor.Target.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ public S05_TestingGroundsEditorTarget(TargetInfo Target)
Type = TargetType.Editor;
}

//
// TargetRules interface.
//

/**
* TargetRules interface.
*/
public override void SetupBinaries(
TargetInfo Target,
ref List<UEBuildBinaryConfiguration> OutBuildBinaryConfigurations,
Expand Down