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"

Crash by playing in GameMode with PlayerController (C++)

Hey Guys, my problem is... ... when I whould like to play my game, my editor crashs. I have an standard GameMode, but with a custom PlayerController. Compiling works.

My Code for the PlayerController: http://pastebin.com/SxMuqa0H My Crashreport: http://pastebin.com/NCPzhdNR

Can anybody help me?

Product Version: UE 4.12
Tags:
more ▼

asked Jul 22 '16 at 08:51 AM in C++ Programming

avatar image

Panakotta00
10 1 4 8

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

2 answers: sort voted first

If you have BSP on your level, then the cause may be in 28 and 29 line of code of your PlayerControll.cpp file.

In line 28 you assume, that whenever you hit anything, it's already an actor, which is wrong. BSP for example isn't a an actor (thus hit.GetActor() returns nullptr), yet it could be detected by your linetrace. I'm not sure if there are any other objects like BSP that would block linetrace despite the fact they aren't actual actors.

Anyway, to fix this you could replace your condition in 28th line to this:

 if (PC_World->LineTraceSingleByChannel(*hit, cm->GetCameraLocation(), *c_loc + *c_dir * 1000, ECC_Pawn) && hit.GetActor())
more ▼

answered Jul 22 '16 at 09:21 AM

avatar image

Atheist91
1.2k 18 23 40

avatar image Panakotta00 Jul 24 '16 at 07:41 PM

Sorry but then the same

avatar image Atheist91 Jul 24 '16 at 08:35 PM

What is a parent class of your APlayerControll class? I'm assuming it's APlayerController?

avatar image Atheist91 Jul 24 '16 at 08:40 PM

If so, your cm variable is null, and you're assuming it's not (line 28 again: cm->GetCameraLocation()).

In line 14, you're trying to cast APlayerController to APlayerCameraManager which is a no-go. Change that line to:

 cm = PlayerCameraManager;

Or you can simply use PlayerCameraManager instead of cm variable.

avatar image Atheist91 Jul 24 '16 at 08:42 PM

Also, not something that important, but in line 11, you don't have to cast 'this' to AActor since APlayerController is deriving from AActor class. You can simply make it

 PC_Actor = this;
avatar image Panakotta00 Jul 25 '16 at 02:32 PM
 PC_Actor = this;

I have no compiling error but an crash with http://pastebin.com/510K6rC3

avatar image Atheist91 Jul 25 '16 at 04:28 PM

It's an additional thing i've seen in your code. Casting APlayerController to AActor shouldn't cause any problems, but it's simply redundant, that's all.

avatar image Panakotta00 Jul 25 '16 at 02:29 PM
 cm = PlayerCameraManager;

Sorry but then I have an compilling error

avatar image Atheist91 Jul 25 '16 at 04:42 PM

What error?

Also, could you show updated .cpp file?

avatar image Panakotta00 Jul 25 '16 at 06:29 PM

So, that was crazy... jet I have no error rather an crash: http://pastebin.com/TFUEJ5R4 an my .cpp file: http://pastebin.com/KFSGqbhR

avatar image Atheist91 Jul 25 '16 at 07:52 PM

Hmm.. Weird. Didn't notice that earlier.

I just tested it and it seems that the issue is with where you're getting your references to world and camera manager. You do that in constructor, while these objects doesn't exist yet.

Moving these:

 PC_World = PC_Actor->GetWorld(); 
 cm = PlayerCameraManager;

To - for example - BeginPlay should solve the issue.

avatar image Panakotta00 Jul 26 '16 at 12:53 PM

Thank you!

avatar image Panakotta00 Jul 26 '16 at 02:51 PM

I have one question, when i play it, my player camera manager moves to the left, why? my code: http://pastebin.com/cbMk0ikr

avatar image Atheist91 Jul 26 '16 at 05:56 PM

This code doesn't look like it can cause such thing. Could you try to comment out your 32nd line and see if it keeps happening?

avatar image Panakotta00 Jul 28 '16 at 01:05 PM

When i do that, with the 35nd Line, then nothing happends.

avatar image Panakotta00 Jul 30 '16 at 09:17 AM

Ok i have add in the 31nd Line cp->AddIgnoredActor(GetPawnOrSpectator());

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

Read comments in answer before

more ▼

answered Jul 26 '16 at 12:55 PM

avatar image

Panakotta00
10 1 4 8

(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