Support
Quality
Security
License
Reuse
Coming Soon for all Libraries!
Currently covering the most popular Java, JavaScript and Python libraries. See a SAMPLE HERE.
kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
Config - saves some global read-only game configurations, such as the player's initial speed, the initial volume of the game, etc.
Data Node - saves arbitrary types of data within tree structures in order to manage various data during game runtime.
Data Table - is intended to invoke game data in the form of pre-configured tables (such as Microsoft Excel sheets). The format of the tables can be customised.
Debugger - displays a debugger window when the game runs in the Unity Editor or in a development build, to facilitate the viewing of runtime logs and debug messages. The user can register their own features to the debugger windows and use them conveniently.
Download - provides the ability to download files. The user is free to set how many downloaders could be used simultaneously.
Entity - provides the ability to manage entities and groups of entities, where an entity is defined as any dynamically created objects in the game scene. It shows or hides entities, attach one entity to another (such as weapons, horses or snatching up another entity). Entities could avoid being destroyed instantly after use, and hence be recycled for reuse.
Event - gives the mechanism for the game logic to fire or observe events. Many modules in the Game Framework fires events after operations, and observing these events will largely decouple game logic modules. The user can define his own game logic events, too.
File System - the virtual file system, based on the concept of disks, manages scattered files in a centralized way, optimizes memory allocation when resources are loaded, and can even load segments of resources. These will drastically enhance the performance of resource loading.
FSM - provides the ability to create, use and destroy finite state machines. It’d be a good choice to use this module for some state-machine-like game logic.
Localization - provides the ability to localise the game. Game Framework not only supports the localisation of texts, but also assets of all kinds. For example, a firework effect in the game can be localised as various versions, so that the player will see a "新年好" - like effect in the Chinese version, while "Happy New Year" - like in the English version.
Network - provides socket connections where TCP is currently supported and both IPv4 and IPv6 are valid. The user can establish several connections to different servers at the same time. For example, the user can connect to a normal game server, and another server for voice chat. The 'Packet' class is ready for inheritance and implemented if the user wants to take use of protocol libraries such as ProtoBuf.
Object Pool - provides the ability to cache objects in pools. It avoids frequent creation and destruction operations of game objects, and hence improves the game performance. Game Framework itself uses object pools, and the user could conveniently create and manage his own pools.
Procedure - is in fact an FSM of the whole lifecycle of the game. It’d be a very good habit to decouple different game states via procedures. For a network game, you probably need procedures of checking resources, updating resources, checking the server list, selecting a server, logging in a server and creating avatars. For a standalone game, you perhaps need to switch between procedures of the menu and the real gameplay. The user could add procedures by simply subclassing and implementing the 'ProcedureBase' class.
Resource - provides only asynchronous interfaces to load resources. We don’t recommend synchronous approaches for better play experience, and Game Framework itself uses a complete system of asynchronous resource loading. We load everything asynchronously, including simple things like data tables and localisation texts, and complex things like entities, scenes and UIs. Meanwhile, Game Framework provides default strategies of memory management (and of course, you could define your own strategies). In most cases, you don't even need to call 'Instantiate' or 'Destroy' when using 'GameObject' instances.
Scene - provides features to manage scenes. It supports simultaneous loading of multiple scenes, and the user is allowed to unload a scene at any time. Therefore partial loading/unloading of scenes could be easily implemented.
Setting - stores player data in key-value pairs by either encapsulating UnityEngine.PlayerPrefs or by saving the data directly to the disk.
Sound - provides features to manage sounds and groups of sounds. The user could set the properties of an audio clip, such as the volume, whether the clip is 2D or 3D, and could even bind the clip to some entity to follow its position.
UI - provides features to manage user interfaces and groups of UIs, such as showing or hiding, activating or deactivating, and depth changing. No matter the user uses the builtin uGUI in Unity or other UI plugins (NGUI, for example), he only needs to subclass 'UIFormLogic' and implement his own UI logic. The UIs could avoid being destroyed instantly after use, and hence be recycled for reuse.
Web Request - provides features of short connections, supports GET and POST methods to send requests to the server and acquire the response data, and allows the user to send simultaneous requests to different servers.
how to make a collision of an actor on a character in C++ UE4?
//.h
UFUNCTION()
void Power();
UFUNCTION()
void ResetPower();
bool bIsPower = false;
//.cpp
void AItem::ResetPower()
{
player->GetMesh()->SetRelativeScale3D(FVector(1.f,1.f,1.f));
}
//.cpp
void AItem::OnBeginOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp,
int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
if(OtherActor->IsA(AProjet2Character::StaticClass()) && !bIsPower)
{
player = Cast<AProjet2Character>(OtherActor);
bIsPower = true;
Power();
}
}
void AItem::OnEndOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp,
int32 OtherBodyIndex)
{
if(OtherActor->IsA(AProjet2Character::StaticClass()) && bIsPower)
{
player = Cast<AProjet2Character>(OtherActor);
bIsPower = false;
ResetPower();
}
}
void AItem::OnBeginOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp,
int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
if(OtherActor->IsA(AProjet2Character::StaticClass()) && !bIsPower)
{
player = Cast<AProjet2Character>(OtherActor);
bIsPower = true;
Power();
}
}
void AItem::OnEndOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp,
int32 OtherBodyIndex)
{
//Clear
}
-----------------------
//.h
UFUNCTION()
void Power();
UFUNCTION()
void ResetPower();
bool bIsPower = false;
//.cpp
void AItem::ResetPower()
{
player->GetMesh()->SetRelativeScale3D(FVector(1.f,1.f,1.f));
}
//.cpp
void AItem::OnBeginOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp,
int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
if(OtherActor->IsA(AProjet2Character::StaticClass()) && !bIsPower)
{
player = Cast<AProjet2Character>(OtherActor);
bIsPower = true;
Power();
}
}
void AItem::OnEndOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp,
int32 OtherBodyIndex)
{
if(OtherActor->IsA(AProjet2Character::StaticClass()) && bIsPower)
{
player = Cast<AProjet2Character>(OtherActor);
bIsPower = false;
ResetPower();
}
}
void AItem::OnBeginOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp,
int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
if(OtherActor->IsA(AProjet2Character::StaticClass()) && !bIsPower)
{
player = Cast<AProjet2Character>(OtherActor);
bIsPower = true;
Power();
}
}
void AItem::OnEndOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp,
int32 OtherBodyIndex)
{
//Clear
}
-----------------------
//.h
UFUNCTION()
void Power();
UFUNCTION()
void ResetPower();
bool bIsPower = false;
//.cpp
void AItem::ResetPower()
{
player->GetMesh()->SetRelativeScale3D(FVector(1.f,1.f,1.f));
}
//.cpp
void AItem::OnBeginOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp,
int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
if(OtherActor->IsA(AProjet2Character::StaticClass()) && !bIsPower)
{
player = Cast<AProjet2Character>(OtherActor);
bIsPower = true;
Power();
}
}
void AItem::OnEndOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp,
int32 OtherBodyIndex)
{
if(OtherActor->IsA(AProjet2Character::StaticClass()) && bIsPower)
{
player = Cast<AProjet2Character>(OtherActor);
bIsPower = false;
ResetPower();
}
}
void AItem::OnBeginOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp,
int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
if(OtherActor->IsA(AProjet2Character::StaticClass()) && !bIsPower)
{
player = Cast<AProjet2Character>(OtherActor);
bIsPower = true;
Power();
}
}
void AItem::OnEndOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp,
int32 OtherBodyIndex)
{
//Clear
}
Why is a function parameter behaving like a variable declaration?
UCLASS()
class BLACKJACK_API APlaying_Card : public AActor
{
...
public:
...
APlaying_Card(int rank, Suit suit);
...
};
APlaying_Card::APlaying_Card(int rank, Suit suit) :
rank(rank), suit(suit) // <-- no ambiguity here!
{
...
if (rank == 1)
{
value = rank; //todo: find a way to make Ace 1 or 11.
faceStr = "Ace";
}
else if (rank <= 10)
{
value = rank;
faceStr = FString::FromInt(rank);
}
else if (rank == 11)
{
value = 10;
faceStr = "Jack";
}
else if (rank == 12)
{
value = 10;
faceStr = "Queen";
}
else if (rank == 13)
{
value = 10;
faceStr = "King";
}
}
-----------------------
UCLASS()
class BLACKJACK_API APlaying_Card : public AActor
{
...
public:
...
APlaying_Card(int rank, Suit suit);
...
};
APlaying_Card::APlaying_Card(int rank, Suit suit) :
rank(rank), suit(suit) // <-- no ambiguity here!
{
...
if (rank == 1)
{
value = rank; //todo: find a way to make Ace 1 or 11.
faceStr = "Ace";
}
else if (rank <= 10)
{
value = rank;
faceStr = FString::FromInt(rank);
}
else if (rank == 11)
{
value = 10;
faceStr = "Jack";
}
else if (rank == 12)
{
value = 10;
faceStr = "Queen";
}
else if (rank == 13)
{
value = 10;
faceStr = "King";
}
}
OnComponentBeginOverlap.AddDynamic says no instance of the function template matches the argument list?
void (_cdecl AAICharacter::*)( AActor*,UPrimitiveComponent*,int32,bool,const FHitResult &)
void (_cdecl AAICharacter::*)(UPrimitiveComponent*, AActor*,UPrimitiveComponent*,int32,bool,const FHitResult &)
UFUNCTION()
void OnBoxOverlapWrapper(UPrimitiveComponent* /*ignored*/, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherIndex, bool bFromSweep, const FHitResult & SweepResult)
{
OnBoxOverlap(OtherActor, OtherComp, OtherIndex, bFromSweep, SweepResult);
}
-----------------------
void (_cdecl AAICharacter::*)( AActor*,UPrimitiveComponent*,int32,bool,const FHitResult &)
void (_cdecl AAICharacter::*)(UPrimitiveComponent*, AActor*,UPrimitiveComponent*,int32,bool,const FHitResult &)
UFUNCTION()
void OnBoxOverlapWrapper(UPrimitiveComponent* /*ignored*/, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherIndex, bool bFromSweep, const FHitResult & SweepResult)
{
OnBoxOverlap(OtherActor, OtherComp, OtherIndex, bFromSweep, SweepResult);
}
UE4: Actor disappears after play is hit
AMyActor::AMyActor()
{
...
Root = CreateDefaultSubobject<USceneComponent>(TEXT("Root"));
RootComponent = Root;
Mesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Mesh"));
Mesh->AttachTo(Root);
...
}
public:
...
UPROPERTY()
USceneComponent* Root;
UPROPERTY(EditAnywhere)
UStaticMeshComponent* Mesh;
...
-----------------------
AMyActor::AMyActor()
{
...
Root = CreateDefaultSubobject<USceneComponent>(TEXT("Root"));
RootComponent = Root;
Mesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Mesh"));
Mesh->AttachTo(Root);
...
}
public:
...
UPROPERTY()
USceneComponent* Root;
UPROPERTY(EditAnywhere)
UStaticMeshComponent* Mesh;
...
Pointer related UE4 crash. Where are my pointers wrong?
ALTPlayer::ALTPlayer()
: WeaponClass(ALTWeapon::StaticClass())
{
}
//~ Begin AActor Interface
virtual void PreInitializeComponents() override;
//~ End AActor Interface
void ALTPlayer::PreInitializeComponents()
{
Super::PreInitializeComponents();
// Fallback to default Weapon class if none was specified.
if (WeaponClass == nullptr)
{
UE_LOG(LogGameMode, Warning, TEXT("No WeaponClass was specified in %s (%s)"), *GetName(), *GetClass()->GetName());
WeaponClass = ALTWeapon::StaticClass();
}
}
-----------------------
ALTPlayer::ALTPlayer()
: WeaponClass(ALTWeapon::StaticClass())
{
}
//~ Begin AActor Interface
virtual void PreInitializeComponents() override;
//~ End AActor Interface
void ALTPlayer::PreInitializeComponents()
{
Super::PreInitializeComponents();
// Fallback to default Weapon class if none was specified.
if (WeaponClass == nullptr)
{
UE_LOG(LogGameMode, Warning, TEXT("No WeaponClass was specified in %s (%s)"), *GetName(), *GetClass()->GetName());
WeaponClass = ALTWeapon::StaticClass();
}
}
-----------------------
ALTPlayer::ALTPlayer()
: WeaponClass(ALTWeapon::StaticClass())
{
}
//~ Begin AActor Interface
virtual void PreInitializeComponents() override;
//~ End AActor Interface
void ALTPlayer::PreInitializeComponents()
{
Super::PreInitializeComponents();
// Fallback to default Weapon class if none was specified.
if (WeaponClass == nullptr)
{
UE_LOG(LogGameMode, Warning, TEXT("No WeaponClass was specified in %s (%s)"), *GetName(), *GetClass()->GetName());
WeaponClass = ALTWeapon::StaticClass();
}
}
TSubclassOf<> isn't storing the class type
UPROPERTY(EditDefaultsOnly, Category = "Setup")
TSubclassOf<class ALaserTagLaser> LaserClass;
QUESTION
how to make a collision of an actor on a character in C++ UE4?
Asked 2022-Jan-12 at 15:32I’m looking to make items that contain powers on unreal engine in c++ like :
When the player steps on it, he wins the Mushroom effect:
So I create my Actor Item which contains the beginoverlap and the power function : Item.h
#pragma once
#include "CoreMinimal.h"
#include "Components/CapsuleComponent.h"
#include "Components/SphereComponent.h"
#include "GameFramework/Actor.h"
#include "Components/StaticMeshComponent.h"
#include "GameFramework/PlayerController.h"
#include "Character/Projet2Character.h"
#include "Item.generated.h"
UCLASS()
class PROJET2_API AItem : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AItem();
protected:
UPROPERTY(EditAnywhere)
USphereComponent* Collider;
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
UFUNCTION()
void OnBeginOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
UFUNCTION()
void OnEndOverlap(class UPrimitiveComponent* OverlappedComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex);
UFUNCTION()
void Power();
AProjet2Character* player;
// Called every frame
virtual void Tick(float DeltaTime) override;
};
Item.cpp
#include "Actor/Item.h"
// Sets default values
AItem::AItem()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
Mesh = CreateDefaultSubobject<UStaticMeshComponent>(FName("Mesh"));
Mesh->SetupAttachment(RootComponent);
RootComponent = Mesh;
Collider = CreateDefaultSubobject<USphereComponent>(FName("Collider"));
Collider->SetupAttachment(Mesh);
}
// Called when the game starts or when spawned
void AItem::BeginPlay()
{
Super::BeginPlay();
Collider->OnComponentBeginOverlap.AddDynamic(this, &AItem::OnBeginOverlap);
Collider->OnComponentEndOverlap.AddDynamic(this, &AItem::OnEndOverlap);
}
void AItem::OnBeginOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp,
int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
if(OtherActor->IsA(AProjet2Character::StaticClass()))
{
Power();
}
}
void AItem::OnEndOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp,
int32 OtherBodyIndex)
{
if(OtherActor->IsA(AProjet2Character::StaticClass()))
{
Power();
}
}
void AItem::Power()
{
player->GetMesh()->SetRelativeScale3D(FVector(1.5f,1.5f,1.5f));
}
// Called every frame
void AItem::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
When I launch the game at the moment I come into contact with the actor, unreal closes and the effect still does not apply to the character. I want to know how to do it? :)
Thank you for your understanding
ANSWER
Answered 2022-Jan-12 at 15:32I didnt quite understand. Do you want the player to step on the object and increase in size and then, when he leaves the object, return it to its original size (1) or keep the size (2)?
//.h
UFUNCTION()
void Power();
UFUNCTION()
void ResetPower();
bool bIsPower = false;
//.cpp
void AItem::ResetPower()
{
player->GetMesh()->SetRelativeScale3D(FVector(1.f,1.f,1.f));
}
1:
//.cpp
void AItem::OnBeginOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp,
int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
if(OtherActor->IsA(AProjet2Character::StaticClass()) && !bIsPower)
{
player = Cast<AProjet2Character>(OtherActor);
bIsPower = true;
Power();
}
}
void AItem::OnEndOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp,
int32 OtherBodyIndex)
{
if(OtherActor->IsA(AProjet2Character::StaticClass()) && bIsPower)
{
player = Cast<AProjet2Character>(OtherActor);
bIsPower = false;
ResetPower();
}
}
2:
void AItem::OnBeginOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp,
int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
if(OtherActor->IsA(AProjet2Character::StaticClass()) && !bIsPower)
{
player = Cast<AProjet2Character>(OtherActor);
bIsPower = true;
Power();
}
}
void AItem::OnEndOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp,
int32 OtherBodyIndex)
{
//Clear
}
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
No vulnerabilities reported
Save this library and start creating your kit
Explore Related Topics
Save this library and start creating your kit