Posts

Spawn

 Unreal UPROPERTY() AActor* theActor; FActorSpawnParameters SpawnParameter; void APlayerChar::BeginPlay() { Super::BeginPlay();     AActor* SpawnActor = GetWorld()->SpawnActor<AActor>(theActor, GetActorLocation(), GetActorRotation(), SpawnParameter); } Unity public GameObject theGameObject; void Update() => Instantiate(theGameObject, transform.position, Quantanion.identity);

Function on time duration

  Unreal void ATestActor::BeginPlay(){ Super::BeginPlay(); GetWorld()->GetTimerManager().SetTimer(functionDelay, this, &ATestActor::theFunction, delayTime, delayLoop); } void ATestActor::Tick(float DeltaTime) { Super::Tick(DeltaTime); if(stopFtimHandlr) GetWorld()->GetTimerManager().ClearAllTimersForObject(this);//GetWorld()->GetTimerManager().ClearTimer(functionDelay); } void ATestActor::theFunction(){ UE_LOG(LogTemp, Display, TEXT("Function work on Particular time period")); } Unity public float delayTime; public float delayLoopTime; [SerializeField] bool stopInvoke; void Start() => InvokeRepeating("theFunction", delayTime, delayLoopTime); private void Update() => if(stopInvoke) CancelInvoke(); void theFunction() => print("Function work on Particular time period");

Ray Tracing

 Unreal void APlayerChar::Tick(float DeltaTime) { Super::Tick(DeltaTime); FHitResult* Outhit; float traceLimit = 100;                 if(GetWorld()->LineTraceSingleByChannel(Outhit, GetComponentLocation(), GetForwardVector() * traceLimit, ECC_Visiblity)) { UE_LOG(LogTemp, Display, TEXT("%s"), *hitOut->GetName());                     DrawDebugLine(GetWorld(),  GetComponentLocation(), GetForwardVector() * traceLimit, FColor::Red, false, 1, 0, 5);//#include "DrawDebugHelpers.h"                 } } Unity void Update() {         RaycastHit hit;         float rayLimit = 100;         if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward), out hit, rayLimit))  { Debug.Log(hit.collider.gameObject.name);             De...

Hit Trigger

 Unreal APlayerChar::APlayerChar() { OnComponentBeginOverlap.AddDynamic(this, &APlayerChar::OnCompHit); }//if not working the AddDynamic Function delegate use on BeginPlay() void APlayerChar::OnOverlapBegin(class UPrimitiveComponent* OverlappedComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult) { //CurrentJumpCount = 0;  GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Green, FString::Printf(TEXT("I Hit: %s"), *OtherComp->GetName()));                  if(OtherComp.ComponentHasTag("theComponent")) UE_LOG(LogTemp, Warning, TEXT("Overlap theComponent")); } Unity [SerializeField] string colliderName; void OnTriggerEnter(Collider collider) => colliderName = collider.gameObject.name;

Hit Any Collider

Unreal APlayerChar::APlayerChar() { GetCapsuleComponent()->OnComponentHit.AddDynamic(this, &APlayerChar::OnCompHit); }//if not working the AddDynamic Function delegate use on BeginPlay()  void APlayerChar::OnCompHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit) { //CurrentJumpCount = 0;                  if(OtherComp != this && OtherComp != NULL) UE_LOG(LogTemp, Warning, TEXT("Collision On Component")); GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Green, FString::Printf(TEXT("I Hit: %s"), *OtherComp->GetName())); } Unity [SerializeField] string collisioName; void OnCollisionEnter(Collision collision) => collisioName = collision.gameObject.name; private void OnGUI() => GUI.Label(new Rect(10, 10, 100, 20), "collision Name = " + collisioName);

Variables On Log

Unreal                 FString MyStringValue = "String";             UE_LOG(LogTemp, Display, TEXT("FString value is: %s"),  *MyStringValue);                 bool MyBoolValue = true; UE_LOG(LogTemp, Display, TEXT("bool value is: %s"),  MyBoolValue? "true" : "false");                 float MyFloatValue = 8; UE_LOG(LogTemp, Display, TEXT("float value is: %f"),  MyFloatValue);                 int MyIntValue = 3; UE_LOG(LogTemp, Display, TEXT("Integer value is: %i"),  MyIntValue); Unity var boolValue = true; var floatValue = 8; var intValue = 3; Debug.Log("bool value is: " + boolValue + "\n" + "float value is: " + floatValue + "\n" + "Integer value is: " + intValue);

If Press AnyKey

 Unreal void APlayerChar::Tick(float DeltaTime) { Super::Tick(DeltaTime); APlayerController* plyrCntrlr = GetWorld()->GetFirstPlayerController(); if(plyrCntrlr->WasInputKeyJustPressed(EKeys::AnyKey)) GEngine->AddOnScreenDebugMessage(-1, 5, FColor::Cyan, TEXT("Key pressed"));//need #include "Engine/GameEngine.h" } Unity bool pressKey; void Update() => pressKey = Input.anyKey | Input.GetKey(KeyCode.E); void OnGUI() { if(pressKey)  GUI.Label(new Rect(10, 10, 100, 20), "Hello World!"); }