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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Creating a mouse controller cuases UE to crash?

So originally what I did was this:

 APlayerController* MyController = GetWorld()->GetFirstPlayerController();

And that didn't work because it permanently screwed up my project folder.

I just presumed that this was an incorrect way of doing it, so next I tried to follow this tutorial, and it did what it said it would do, which was cool, except I also needed to work with the mouse after, so I created C++ version of the blueprint file they got us to make in the tutorial and it looked like this:

 // Fill out your copyright notice in the Description page of Project Settings.
 
 #include "Taank.h"
 #include "Mouse_PlayerController_CPP.h"
 
 AMouse_PlayerController_CPP::AMouse_PlayerController_CPP()
 {
 
 
     bShowMouseCursor = true;
     bEnableClickEvents = true;
     bEnableMouseOverEvents = true;
     
 }

And then when I placed the code to try and use it in my pawn cpp file:

 AMouse_PlayerController_CPP MouseControll;

(I did have the correct include in the code) and then it did the exact same thing!

I think this is a problem on UE side now, can anyone please help me out here? Thanks

Product Version: UE 4.10
Tags:
more ▼

asked Dec 14 '15 at 03:21 AM in Bug Reports

avatar image

It_
21 1 2 3

avatar image Doug E ♦♦ STAFF Dec 14 '15 at 08:27 PM

Hey It_-

The tutorial you linked explains setting up the player controller and game mode to use that player controller. You shouldn't have to add the player controller as a variable to your pawn, rather the pawn will automatically use whatever player controller is set in the GameMode. If you are trying to setup specific controls for a character based on input you can set the input button through the editor and then define what that input does in code by writing the function for the action to be taken and then bind that function in the SetupPlayerInputComponent() function of the pawn/character.

Cheers

Doug Wilson

avatar image It_ Dec 15 '15 at 01:55 PM

Sorry to be blunt, but you haven't told me anything I don't know (I've already setup keyboard controls perfectly fine), and the problem continues to persist; the problem being that I wanna get my pawn to respond to mouse moments but I have no idea on how to use the mouse in my code without permanently messing up my project.

avatar image Doug E ♦♦ STAFF Dec 15 '15 at 03:45 PM

It may help to know how you're trying to use the mouse. Are you trying to implement a "click and move" system or have the character constantly follow where the mouse is on screen? I tried following the setup you mentioned by adding a class based on PlayerController with the code you posted in the constructor and then add a class based on Pawn with a pointer to my custom PlayerController class. After compiling I had no issue returning to the editor or closing/reopening the editor. If you've reproduced the behavior over multiple projects, could you explain the steps that cause it to occur in a new project with no added content?

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

1 answer: sort voted first

Sorry for my late response. I found a way to get it to work, but I'm not sure if it's elegant or not. The problem I was having was that I wanted to use the DeprojectMousePositionToWorld() function but was unable to set up an APlayerController* variable in the way I described in the first 2 lines of my question. I'm still not entirely sure what the problem was, but my best guess is that the constructor method for my pawn class is executed before the controller file in initilialised, or something like that. Anyway, I solved the problem by instantiating my APlayerController* variable under the BenginPlay() function instead of the constructor. Now I have a new problem of spawning an actor causes UE to crash. So many crashes :/ Aww well. I'll figure this one out.

more ▼

answered Dec 18 '15 at 03:04 AM

avatar image

It_
21 1 2 3

(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