You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 27, 2026. It is now read-only.
* @details Sets up the audio component, static mesh, and scene root. Binds the OnOverlapBegin function to the OnComponentBeginOverlap event of the static mesh
SetRootComponent(SceneRoot); // Set the scene root as the root component
15
+
StaticMesh->SetupAttachment(SceneRoot); // Attach the static mesh to the scene root
16
+
Audio->SetupAttachment(StaticMesh); // Attach the audio component to the static mesh
17
+
SphereCollider->SetupAttachment(StaticMesh); // Attach the sphere collider to the static mesh
18
+
19
+
//StaticMesh->SetCollisionProfileName("OverlapAll"); // Set the collision profile of the static mesh to overlap all
20
+
21
+
SphereCollider->OnComponentBeginOverlap.AddDynamic(this, &ABush::OnOverlapBegin); // Bind the OnOverlapBegin function to the OnComponentBeginOverlap event of the static mesh
22
+
23
+
Audio->bAutoActivate = false; // Don't play the audio component on begin play
24
+
}
25
+
26
+
/**
27
+
* @brief Function that is called when the game starts or when spawned
28
+
* @details Stops the audio component from playing on begin play
29
+
*/
30
+
voidABush::BeginPlay()
31
+
{
32
+
Super::BeginPlay();
33
+
34
+
Audio->Stop(); // Stop the audio component from playing on begin play
35
+
}
36
+
37
+
/**
38
+
* @brief Function that is called when the actor is being overlapped by another actor
39
+
* @details Plays the sound if it exists and is not already playing
40
+
*
41
+
* @param OverlappedComponent The component that is being overlapped
42
+
* @param OtherActor The actor that is overlapping
43
+
* @param OtherComp The component of the actor that is overlapping
44
+
* @param OtherBodyIndex The body index of the actor that is overlapping
45
+
* @param bFromSweep Whether the overlap was from a sweep
0 commit comments