FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
unrealcpp/UnrealCPPProjectile.cpp at master · Harrison1/unrealcpp · GitHub
Harrison1
/
unrealcpp
Public
Notifications
You must be signed in to change notification settings
Fork
223
Star
1.3k
Code
Issues
1
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
unrealcpp
/
UnrealCPPProjectile.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
43 lines (35 loc) · 1.74 KB
Breadcrumbs
unrealcpp
/
UnrealCPPProjectile.cpp
Copy path
File metadata and controls
43 lines (35 loc) · 1.74 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//
Copyright 1998-2018 Epic Games, Inc. All Rights Reserved.
#
include
"
UnrealCPPProjectile.h
"
#
include
"
GameFramework/ProjectileMovementComponent.h
"
#
include
"
Components/SphereComponent.h
"
AUnrealCPPProjectile::AUnrealCPPProjectile
()
{
//
Use a sphere as a simple collision representation
CollisionComp = CreateDefaultSubobject<USphereComponent>(
TEXT
(
"
SphereComp
"
));
CollisionComp->
InitSphereRadius
(
5
.
0f
);
CollisionComp->
BodyInstance
.
SetCollisionProfileName
(
"
Projectile
"
);
CollisionComp->
OnComponentHit
.
AddDynamic
(
this
, &AUnrealCPPProjectile::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
));
CollisionComp->
CanCharacterStepUpOn
= ECB_No;
//
Set as root component
RootComponent = CollisionComp;
//
Use a ProjectileMovementComponent to govern this projectile's movement
ProjectileMovement = CreateDefaultSubobject<UProjectileMovementComponent>(
TEXT
(
"
ProjectileComp
"
));
ProjectileMovement->
UpdatedComponent
= CollisionComp;
ProjectileMovement->
InitialSpeed
=
3000
.
f
;
ProjectileMovement->
MaxSpeed
=
3000
.
f
;
ProjectileMovement->
bRotationFollowsVelocity
=
true
;
ProjectileMovement->
bShouldBounce
=
true
;
//
Die after 3 seconds by default
InitialLifeSpan =
3
.
0f
;
}
void
AUnrealCPPProjectile::OnHit
(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse,
const
FHitResult& Hit)
{
//
Only add impulse and destroy projectile if we hit a physics
if
((OtherActor !=
NULL
) && (OtherActor !=
this
) && (OtherComp !=
NULL
) && OtherComp->
IsSimulatingPhysics
())
{
OtherComp->
AddImpulseAtLocation
(
GetVelocity
() *
100
.
0f
,
GetActorLocation
());
Destroy
();
}
}
Back
|
FazBrowse Home
|
New Git URL