Jump to content
  • Advertisement
MarcusAseth

Crashing Unreal Engine with minimal effort

Recommended Posts

I need some help to understand what I'm doing wrong here x_x

Here's my step:

1) create a new C++ project with starting content, drop a door in the scene.

2)Add a C++ component to the door called OpenDoor

3)add a variable in the .h and initialize it in the .cpp  (code below)

When I compile this, the editor crash and any future attempt to open the project won't succede. What mistake did I made? Furthermore, if said mistake is made, is the project lost forever or there is a way to restore it? x_x  Cause if wathever silly mistake I've made, if it's all it takes to corrupt and lose an entire project, then I'm done with Unreal Editor... x_x

OpenDoor.h:

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "OpenDoor.generated.h"


UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class BUILDINGESCAPE_API UOpenDoor : public UActorComponent
{
	GENERATED_BODY()

public:	
	// Sets default values for this component's properties
	UOpenDoor();

protected:
	// Called when the game starts
	virtual void BeginPlay() override;

public:	
	// Called every frame
	virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;

private:

	float DoorYaw;
	
};

 

OpenDoor.cpp:

// Fill out your copyright notice in the Description page of Project Settings.

#include "OpenDoor.h"
#include "GameFramework/Actor.h"

// Sets default values for this component's properties
UOpenDoor::UOpenDoor()
	:DoorYaw{GetOwner()->GetActorRotation().Yaw}
{
	// Set this component to be initialized when the game starts, and to be ticked every frame.  You can turn these features
	// off to improve performance if you don't need them.
	PrimaryComponentTick.bCanEverTick = true;

	// ...
}


// Called when the game starts
void UOpenDoor::BeginPlay()
{
	Super::BeginPlay();

	// ...
	
}


// Called every frame
void UOpenDoor::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
	Super::TickComponent(DeltaTime, TickType, ThisTickFunction);

	// ...
}

 

Edited by MarcusAseth

Share this post


Link to post
Share on other sites
Advertisement

Most likely GetOwner() is crashing or returning nullptr. Don't call functions like that in the constructor, because you have no idea what state the object hierarchy will be in. The correct place to initialise any non-trivial values in UE4 is BeginPlay(). (Or maybe InitializeComponent, or similar.)

Share this post


Link to post
Share on other sites

Kylotain covered the most likely culprit, so I'll focus on just this bit:

7 minutes ago, MarcusAseth said:

Furthermore, if said mistake is made, is the project lost forever or there is a way to restore it?

Open the file in a normal text editor and either fix the code or comment the offending code out. This should allow you to open the project in Unreal again.

Share this post


Link to post
Share on other sites

Thanks Kylotan, I was starting suspecting the same thing.

@Lactose : I have removed all changes I had made from the .cpp and .h files, saved, closed VC and restarted UE, launched my project, but still getting the same error/crash before the projects even manage to finish to load. How is this even possible?

Any chance a copy of the offending file has been created in some cache folder and is still being used while my original is ignored?

Edited by MarcusAseth

Share this post


Link to post
Share on other sites
3 minutes ago, MarcusAseth said:

Any chance a copy of the offending file has been created in some cache folder and is still being used while my original is ignored?

Not that I know of.

What does your code look like after your recent changes?

EDIT: Or rebuild in VS, like Kylotan mentions :)

Share this post


Link to post
Share on other sites

@Lactose: Here's the code (below)

As you can see I've removed all the things added by me.

I think I've just found the easiest way to break everything, try those 3 steps yourself, you'll see... :D

OpenDoor.h:

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "OpenDoor.generated.h"


UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class BUILDINGESCAPE_API UOpenDoor : public UActorComponent
{
	GENERATED_BODY()

public:	
	// Sets default values for this component's properties
	UOpenDoor();

protected:
	// Called when the game starts
	virtual void BeginPlay() override;

public:	
	// Called every frame
	virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;

	
};

OpenDoor.cpp:

// Fill out your copyright notice in the Description page of Project Settings.

#include "OpenDoor.h"

// Sets default values for this component's properties
UOpenDoor::UOpenDoor()
{
	// Set this component to be initialized when the game starts, and to be ticked every frame.  You can turn these features
	// off to improve performance if you don't need them.
	PrimaryComponentTick.bCanEverTick = true;

	// ...
}


// Called when the game starts
void UOpenDoor::BeginPlay()
{
	Super::BeginPlay();

	// ...
	
}


// Called every frame
void UOpenDoor::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
	Super::TickComponent(DeltaTime, TickType, ThisTickFunction);

	// ...
}

 

Edited by MarcusAseth

Share this post


Link to post
Share on other sites
11 minutes ago, Kylotan said:

Have you tried a rebuild in Visual Studio?

Ops, I missed this reply, just tried and it fixed, thanks again @Kylotan!! :D

EDIT: did I've found a random way to zoom the emoticon above? I see it zoomed, wtf is wrong today with me and technology?! Breaking wathever I touch... ç_ç

Edited by MarcusAseth

Share this post


Link to post
Share on other sites

  • Advertisement
  • Advertisement
  • Popular Tags

  • Similar Content

    • By Gregory Aaron Martin
      I'm writing a sprawling fantasy series. I've written shorter stories in the world I'm creating. I want to turn one of those short stories into a game. It can be 2D. It's about dragons. There's a story arc below that shows a starting point and an ending point. Details will be given if there's anyone interested. I'm a storyteller but I don't have much knowledge on game development. It would be an adventure game with light rpg elements. 
       
      Synopsis: A young man with a very special gift returns to his mountainous home to find it invaded by a cult. The community he's been a part of his whole life has been cut off by the king to ensure the cult's influence remains limited as it's very influential. This cult believes the dragon they follow and worship rests in the mountains and with the king pulling his soldiers out, the cult can begin its dig underground. The young man learns that the last individual with the same special gift who held a coveted seat on the council was killed by the cult during the cult's takeover of the village community. The young man, like others with the same special ability as him, vied for the seat on the council but he was turned away either for his own safety or because of council secrets. The cult has its own members with this same special ability and they're very intimidating. The community is oppressed for months. Tired of this oppression and feeling abandoned by his king, the young man sets out with a few new comrades to battle this cult, putting on display his own talent with this special gift.They make it their mission to sabotage the cult's dig into the mountains in hopes the cult doesn't awaken their dragon. They also make it their mission to defeat the cult members who posses the special ability. They are successful with this and he is appointed to the coveted seat on the council. 
       
      Thanks
    • By nilkun
      Hello everyone!
      First time posting in the forum.
      I've just completed my first game ever ( C++ / SDL ), and I am feeling utterly proud. It is a small game resembling Missile Command. The code is a mess, but it is my mess! In the process of making the game, I developed my own little game engine.
      My question is, where would be a good place to spread the news to at least get some people to try the game?
    • By Paul Bto
      State of the search
      I'm not looking / I'm still looking
       
      Description
      It is a third person game where you join more players to fight against bosses in the PvE style of the mmorpg, looking for online companions to help you defeat your enemy, where everyone does their respective work, such as tank, dps or heal, in groups of 5 or 10 players.
      The difference with other mmorpg is that here, since there is no open world, you will not have to go through it doing hundreds of missions and using many hours to get to the content that really interests you, which, in the case of PvE, are the dungeons and raids.
       
      Objectives of the project
      For this project we will first make a demo that will only be the boss of a 5 player dungeon.
      The first phase of this project is to release a video gameplay for crowdfunding (kickstarter maybe), so we will focus more on the visual, which could be falsified if the mechanics do not work. If the crowdfunding gives green light would be the game, which if in turn would work would be updated in the future with more dungeons and bands. The ideal would be to make a playable demo.
       
      Compensation
      If this game generates benefits outside crowdfunding, the profits will be distributed depending on the work and disbursement of each one.
       
      Technology
      Unreal. If you want to learn how to use this software with the project, you can.
       
      Required profiles
      - At the moment 2 Programmers (if has multiplayer knowledge in Unreal better).
       
      - 1 2D Artist to make the interface design and some concepts. You are going to try make interfaces like this:

      It would be ideal if you can devote at least 7 hours by week.
      It is a plus if you have experience with high level PvE content in some mmorpg.
       
      Team structure
      Pablo. Environment artist.
      Diego. Character artist.
       
      Web
      Waiting until the equipment is assembled.
       
      Contact
      pablo.barreto.jimenez@gmail.com
       
      Additional Information
      I have the GDD, it depends on the work but, I think the demo could be done in 6 months.
      Here I leave some images of what I did of the project in Unity, where basically I have been testing (The project will be done in Unreal):



       
      Desired feedback
      If you think you can give me some advice about the project, feel free to give your opinion.
       
    • By owenjr
      Hi, I'm a Multimedia Engineering student. I am about to finish my dergree and I'm already thinking about what topic to cover in my final college project.
      I'm interested in the procedural animation with c++ and OpenGL of creatures, something like a spider for example. Can someone tell me what are the issues I should investigate to carry it out? I understand that it has some dependence on artificial intelligence but I do not know to what extent. Can someone help me to find information about it? Thank you very much.
       
      Examples: 
      - Procedural multi-legged walking animation
      - Procedural Locomotion of Multi-Legged Characters in Dynamic Environments
    • By davejones
      A developer I am working with has sent me a project that when packaged is in VR mode, however its not supposed to be. So when I package the project to windows in unreal engine 4, the screen is split in 2 as if its VR. Would anyone know how to get the project out of VR mode so that its just a 3D game? I have disabled VR  plugins and chekced through the project settinsg to untick any VR setting, but still not managed to get it out of VR mode. 
    • By Andrew Parkes
      I am a talented 2D/3D artist with 3 years animation working experience and a Degree in Illustration and Animation. I have won a world-wide art competition hosted by SFX magazine and am looking to develop a survival game. I have some knowledge of C sharp and have notes for a survival based game with flexible storyline and PVP. Looking for developers to team up with. I can create models, animations and artwork and I have beginner knowledge of C sharp with Unity. The idea is Inventory menu based gameplay and is inspired by games like DAYZ.
      Here is some early sci-fi concept art to give you an idea of the work level. Hope to work with like minded people and create something special. email me andrewparkesanim@gmail.com.
      Developers who share the same passion please contact me, or if you have a similar project and want me to join your team email me. 
      Many thanks, Andrew.

    • By mike44
      Hi
      saw in dependency walker that my app still needs msvcp140d.dll even after disabling debug.
      What did I forget in the VS2017 release settings? After setting to multithreaded dll I get linker errors.
      Thanks
       
    • By 3dmodelerguy
      So I have been playing around with yaml-cpp as I want to use YAML for most of my game data files however I am running into some pretty big performance issues and not sure if it is something I am doing or the library itself.
      I created this code in order to test a moderately sized file:
      Player newPlayer = Player(); newPlayer.name = "new player"; newPlayer.maximumHealth = 1000; newPlayer.currentHealth = 1; Inventory newInventory; newInventory.maximumWeight = 10.9f; for (int z = 0; z < 10000; z++) { InventoryItem* newItem = new InventoryItem(); newItem->name = "Stone"; newItem->baseValue = 1; newItem->weight = 0.1f; newInventory.items.push_back(newItem); } YAML::Node newSavedGame; newSavedGame["player"] = newPlayer; newSavedGame["inventory"] = newInventory; This is where I ran into my first issue, memory consumption.
      Before I added this code, the memory usage of my game was about 22MB. After I added everything expect the YAML::Node stuff, it went up to 23MB, so far nothing unexpected. Then when I added the YAML::Node and added data to it, the memory went up to 108MB. I am not sure why when I add the class instance it only adds like 1MB of memory but then copying that data to a YAML:Node instance, it take another 85MB of memory.
      So putting that issue aside, I want want to test the performance of writing out the files. the initial attempt looked like this:
      void YamlUtility::saveAsFile(YAML::Node node, std::string filePath) { std::ofstream myfile; myfile.open(filePath); myfile << node << std::endl; myfile.close(); } To write out the file (that ends up to be about 570KB), it took about 8 seconds to do that. That seems really slow to me.
      After read the documentation a little more I decide to try a different route using the YAML::Emitter, the implemntation looked like this:
      static void buildYamlManually(std::ofstream& file, YAML::Node node) { YAML::Emitter out; out << YAML::BeginMap << YAML::Key << "player" << YAML::Value << YAML::BeginMap << YAML::Key << "name" << YAML::Value << node["player"]["name"].as<std::string>() << YAML::Key << "maximumHealth" << YAML::Value << node["player"]["maximumHealth"].as<int>() << YAML::Key << "currentHealth" << YAML::Value << node["player"]["currentHealth"].as<int>() << YAML::EndMap; out << YAML::BeginSeq; std::vector<InventoryItem*> items = node["inventory"]["items"].as<std::vector<InventoryItem*>>(); for (InventoryItem* const value : items) { out << YAML::BeginMap << YAML::Key << "name" << YAML::Value << value->name << YAML::Key << "baseValue" << YAML::Value << value->baseValue << YAML::Key << "weight" << YAML::Value << value->weight << YAML::EndMap; } out << YAML::EndSeq; out << YAML::EndMap; file << out.c_str() << std::endl; } While this did seem to improve the speed, it was still take about 7 seconds instead of 8 seconds.
      Since it has been a while since I used C++ and was not sure if this was normal, I decided to for testing just write a simple method to manually generate the YAMLin this use case, that looked something like this:
      static void buildYamlManually(std::ofstream& file, SavedGame savedGame) { file << "player: \n" << " name: " << savedGame.player.name << "\n maximumHealth: " << savedGame.player.maximumHealth << "\n currentHealth: " << savedGame.player.currentHealth << "\ninventory:" << "\n maximumWeight: " << savedGame.inventory.maximumWeight << "\n items:"; for (InventoryItem* const value : savedGame.inventory.items) { file << "\n - name: " << value->name << "\n baseValue: " << value->baseValue << "\n weight: " << value->weight; } } This wrote the same file and it took about 0.15 seconds which seemed a lot more to what I was expecting.
      While I would expect some overhead in using yaml-cpp to manage and write out YAML files, it consuming 70X+ the amount of memory and it being 40X+ slower in writing files seems really bad.
      I am not sure if I am doing something wrong with how I am using yaml-cpp that would be causing this issue or maybe it was never design to handle large files but was just wondering if anyone has any insight on what might be happening here (or an alternative to dealing with YAMLin C++)?
    • By 3dmodelerguy
      So I am trying to using Yaml as my game data files (mainly because it support comments, is a bit easier to read than JSON, and I am going to be working in these files a lot) with C++ and yaml-cpp (https://github.com/jbeder/yaml-cpp) seems like the most popular library for dealing with it however I am running into an issue when using pointers.
      Here is my code:
      struct InventoryItem { std::string name; int baseValue; float weight; }; struct Inventory { float maximumWeight; std::vector<InventoryItem*> items; }; namespace YAML { template <> struct convert<InventoryItem*> { static Node encode(const InventoryItem* inventoryItem) { Node node; node["name"] = inventoryItem->name; node["baseValue"] = inventoryItem->baseValue; node["weight"] = inventoryItem->weight; return node; } static bool decode(const Node& node, InventoryItem* inventoryItem) { // @todo validation inventoryItem->name = node["name"].as<std::string>(); inventoryItem->baseValue = node["baseValue"].as<int>(); inventoryItem->weight = node["weight"].as<float>(); return true; } }; template <> struct convert<Inventory> { static Node encode(const Inventory& inventory) { Node node; node["maximumWeight"] = inventory.maximumWeight; node["items"] = inventory.items; return node; } static bool decode(const Node& node, Inventory& inventory) { // @todo validation inventory.maximumWeight = node["maximumWeight"].as<float>(); inventory.items = node["items"].as<std::vector<InventoryItem*>>(); return true; } }; } if I just did `std::vector<InventoryItem> items` and had the encode / decode use `InventoryItem& inventoryItem` everything works fine however when I use the code above that has it as a pointer, I get the following error from code that is part of the yaml-cpp library:
      impl.h(123): error C4700: uninitialized local variable 't' used The code with the error is:
      template <typename T> struct as_if<T, void> { explicit as_if(const Node& node_) : node(node_) {} const Node& node; T operator()() const { if (!node.m_pNode) throw TypedBadConversion<T>(node.Mark()); T t; if (convert<T>::decode(node, t)) // NOTE: THIS IS THE LINE THE COMPILER ERROR IS REFERENCING return t; throw TypedBadConversion<T>(node.Mark()); } }; With my relative lack of experience in C++ and not being able to find any documentation for yaml-cpp using pointers, I am not exactly sure what is wrong with my code.
      Anyone have any ideas what I need to change with my code? 
    • By Gnollrunner
      I already asked this question on stack overflow, and they got pissed at me, down-voted me and so forth, LOL .... so I'm pretty sure the answer is NO, but I'll try again here anyway just in case..... Is there any way to get the size of a polymorphic object at run-time? I know you can create a virtual function that returns size and overload it for each child class, but I'm trying to avoid that since (a) it takes a virtual function call and I want it to be fast and (b) it's a pain to have to include the size function for every subclass. I figure since each object has a v-table their should be some way since the information is there, but perhaps there is no portable way to do it.
  • Advertisement
  • Popular Now

  • Forum Statistics

    • Total Topics
      631401
    • Total Posts
      2999864
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!