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"

How can I fix crashes that shouldn't be happening anymore?

Ok. So I know this title is a little weird, but let me explain. So I tried using a casting method to cast from Character to a derivative of Character. I kept getting a crash due to failed casting, so I removed it, and still getting the same crash. So I need to know how to "update" my project to fix this, because I tried compiling it and it still thinks theres an issue.

 void AMyDoor::Tick( float DeltaTime )
     Super::Tick( DeltaTime );
     AMyPlayerCharacter* Character = NewObject<AMyPlayerCharacter>(this);
     UGameplayStatics::GetPlayerPawn(Character, 0);
     FVector ThisPosition = GetActorLocation();
     FVector PlayerPosition = Character->GetActorLocation();
     float Dist = FVector::Dist(PlayerPosition, ThisPosition);
     if (Dist <= BuyDistance)
         Character->bIsNearDoor = true;
         Character->bIsNearDoor = false;

Product Version: UE 4.11
more ▼

asked May 09 '16 at 04:48 PM in C++ Programming

avatar image

32 9 16 22

avatar image roomon1 May 09 '16 at 06:54 PM

Hi AWPlays49,

I'd love to help, but I'm not yet clear on what exactly the problem is. The trick with crashes is that they usually include a stack trace that helps locate the problem. Without that, I suspect we'll be able to provide only limited assistance. Can you reproduce the problem and post the stack trace that appears in the crash window?

As for your casting problem, I'm guessing that the object you're trying to cast isn't the one you mean. Specifically, I suspect you may be trying to cast an object that isn't derived from ACharacter. Can you post the code you were using before so that I can try to see what might have been going wrong?

Also, since this problem is occurring in your AMyDoor class, can you give a little more information about that class? In particular, I'd like to know what class(es) it derives from as it descends from the Unreal classes.

Lastly, looking at the function you've posted, it looks like you'll be spawning a new instance of the AMyPlayerCharacter class every time a AMyDoor ticks. I don't know your tick settings, but I suspect this could create a rather large number of AMyPlayerCharacters when you don't really need to. (It may also be destroying them again when they are no longer referenced.) This could certainly cause performance issues down the road and might even cause other problems too. Can you explain a little about what you're trying to do in that function?



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

0 answers: sort voted first
Be the first one to answer this question
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