x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

UE 4.21 Crashing

Hey all, So everything worked untill I made an edit within a c++ class that is baised on an actor the issue is I've added a new method in the c++ class auto generated by UE the error it throws in the crash dump is

Exception Code: 0xC0000005

Exception Information: The thread tried to read from or write to a virtual address for which it does not have the appropriate access.

Here's the Tank.h

 // Fill out your copyright notice in the Description page of Project Settings.
 
 #pragma once
 
 #include "CoreMinimal.h"
 #include "GameFramework/Pawn.h"
 #include "Tank.generated.h"
 
 UCLASS()
 class BATTLETANK_API ATank : public APawn
 {
     GENERATED_BODY()
 
 public:
 
     void AimAt(FVector OutHitLocation);
 
 private:
     // Sets default values for this pawn's properties
     ATank();
 
     // Called when the game starts or when spawned
     virtual void BeginPlay() override;
     // Called every frame
     virtual void Tick(float DeltaTime) override;
 
     // Called to bind functionality to input
     virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
 
 };

Here's the method in the cpp file

 void ATank::AimAt(FVector OutHitLocation)
 {
     auto OurTankName = GetName();
     UE_LOG(LogTemp, Warning, TEXT("%s aiming at %s"), (*OurTankName, *OutHitLocation.ToString()))
 }

 

And the calling method in my player controller

 void AMyTankPlayerController::AimTowardsCrosshair() const
 {
     if (!GetControlledTank())
     {
         return;
     }
     
     FVector OutHitLocation;
     if (GetSightRayHitLocation(OutHitLocation))
     {
         GetControlledTank()->AimAt(OutHitLocation);
     }
     
 }


Product Version: UE 4.21
Tags:
more ▼

asked Dec 24 '18 at 07:30 PM in C++ Programming

avatar image

Neonzz
7 2 2 4

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

I'm not 100% sure this is the reason, but you don't need the brackets around the params in your log statement. So:

 UE_LOG(LogTemp, Warning, TEXT("%s aiming at %s"), (*OurTankName, *OutHitLocation.ToString()))

becomes:

 UE_LOG(LogTemp, Warning, TEXT("%s aiming at %s"), *OurTankName, *OutHitLocation.ToString());
more ▼

answered Jan 01 '19 at 06:55 PM

avatar image

phil_me_up
1.5k 6 6 12

avatar image Neonzz Jan 01 '19 at 07:07 PM

That worked thank you

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question