Can't compile on ue and have : was modified or is new

i can’t open my project ??? i got this : LoginId:acafe82f4b82820125c4a99c7727e295
EpicAccountId:14305a20854e46d1b217288d1d7b4e74

Unhandled Exception: EXCEPTION_ACCESS_VIOLATION writing address 0x0000000000000030

UnrealEditor_MultiplyOrRelease_4766!ABCRouge::ABCRouge() [C:\Users\slnob\OneDrive\Documents\Unreal Projects\MultiplyOrRelease\Source\MultiplyOrRelease\BCRouge.cpp:27]
UnrealEditor_CoreUObject
UnrealEditor_CoreUObject
UnrealEditor_CoreUObject
UnrealEditor_CoreUObject
UnrealEditor_CoreUObject
UnrealEditor_Core
UnrealEditor_Core
UnrealEditor_Projects
UnrealEditor_Projects
UnrealEditor
UnrealEditor
UnrealEditor
UnrealEditor
UnrealEditor
UnrealEditor
UnrealEditor
kernel32
ntdll

What is on line 27 of BCRouge.cpp?

You probably need a nullptr check before trying to access a memory address.

And i dell the line 27 but nothing change. This probleme appeared with this line of code :
//PhysMat->Friction = 0;

I had this : PhysMat->Friction = 0;
But i remove it but nothing changed …

post the code for BCRouge.cpp. I’ll check if there are any other problems.
there could be a problem either when trying to access PhysMat if it’s not set or when you try to set the physics material override if it or the mesh you are setting it on are nulls

Ok, but despite the fact that i have changed the code, the error is still the same.

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

include “MyGameInstance.h”
include “Kismet/GameplayStatics.h”
include "Runtime/Engine/Classes/Components/StaticMeshComponent.h "
include “PhysicalMaterials/PhysicalMaterial.h”

include “BCRouge.h”

// Sets default values
ABCRouge::ABCRouge()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don’t need it.
PrimaryActorTick.bCanEverTick = true;

BCRougeMeshPhys = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("Skeletal Mesh Comp Phys"));
BCRougeMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Static Mesh Comp"));	

UStaticMesh* SphereMesh = ConstructorHelpers::FObjectFinder<UStaticMesh>(TEXT("StaticMesh'/Engine/BasicShapes/Sphere.Sphere'")).Object;
BCRougeMesh->SetStaticMesh(SphereMesh);
BCRougeMesh->SetSimulatePhysics(true);
BCRougeMesh->SetEnableGravity(false);

BCRougeMeshPhys->SetPhysMaterialOverride(PhysMat);
BCRougeMesh->SetPhysMaterialOverride(PhysMat);

   //line 27 and before : PhysMat->Friction = 0;
BCRougeMovement = CreateDefaultSubobject<UProjectileMovementComponent>(TEXT("ProjectileMovementComp")); 
BCRougeMovement->InitialSpeed = 800;
BCRougeMovement->MaxSpeed = 8500;
BCRougeMovement->Bounciness = 1;
BCRougeMovement->Friction = 0;
BCRougeMovement->Velocity = (FVector(0.f, -1.f, 0.f));
//RootComponent = BCRougeMovement;

RootComponent = BCRougeMesh;

}

// Called when the game starts or when spawned
void ABCRouge::BeginPlay()
{
Super::BeginPlay();

//ConstructorHelpers::FObjectFinder<UStaticMeshComponent>MeshRef(TEXT("Game/ThirdPerson/Meshes/CubeMesh.CubeMesh"));
//BCRougeMesh->SetStaticMesh(MeshRef);

//ConstructorHelpers::FObjectFinder<UStaticMesh>MeshAsset(TEXT("StaticMesh'/Game/CubeMesh.CubeMesh"));
//UStaticMesh* Asset = MeshAsset.Object;

//BCRougeMesh->SetStaticMesh(Asset);

}

// Called every frame
void ABCRouge::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);

UMyGameInstance* MyGameInstance = Cast<UMyGameInstance>(UGameplayStatics::GetGameInstance(GetWorld()));
if (MyGameInstance)
{
	//MyGameInstance->PointBalle2++;
}

}

apparently, doing this enable my programme to work : 1. delete intermediate and binaries folders.
2. regenerate the project.
3. rebuild
4. and try again.
does it still happen?

It’s ok, i had to delete intermediate and binaries folders. If i had well anderstand, the PhysMat created is a PhysicalMaterial that i have to set in the cdo ? If yes, how do i do this ? As you see i tried PhysMat->Friction = 0; but it made ue crash.
Thanks for following my project and answering my question since the beginning !

.h

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

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "BCRouge.generated.h"

class UProjectileMovementComponent;

UCLASS()
class YOURGAME_API ABCRouge : public AActor
{
	GENERATED_BODY()
	
public:	
	// Sets default values for this actors properties
	ABCRouge();

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

public:	
	// Called every frame
	virtual void Tick(float DeltaTime) override;

	UPROPERTY(BlueprintReadWrite,EditAnywhere)
	TObjectPtr<UProjectileMovementComponent> BCRougeMovement;

	UPROPERTY(BlueprintReadWrite, EditAnywhere)
	TObjectPtr<USkeletalMeshComponent> BCRougeMeshPhys;


	UPROPERTY(BlueprintReadWrite, EditAnywhere)
	TObjectPtr<UStaticMeshComponent> BCRougeMesh;

	UPROPERTY(BlueprintReadWrite, EditAnywhere)
	UPhysicalMaterial* PhysMat;
	



};

cpp

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


#include "BCRouge.h"
#include "GameFramework/ProjectileMovementComponent.h"
#include "Kismet/GameplayStatics.h"
#include "MyGameInstance.h"

// Sets default values


ABCRouge::ABCRouge()
{


    PrimaryActorTick.bCanEverTick = true;
    BCRougeMeshPhys = CreateDefaultSubobject <USkeletalMeshComponent>(TEXT("Skeletal Mesh Comp Phys"));
    BCRougeMesh = CreateDefaultSubobject <UStaticMeshComponent>(TEXT("Static Mesh Comp"));

    UStaticMesh* SphereMesh = ConstructorHelpers::FObjectFinder <UStaticMesh>(TEXT("StaticMesh'/Engine/BasicShapes/Sphere.Sphere'")).Object;
    BCRougeMesh->SetStaticMesh(SphereMesh);
    BCRougeMesh->SetSimulatePhysics(true);
    BCRougeMesh->SetEnableGravity(false);

    if (PhysMat != nullptr) {
        BCRougeMeshPhys->SetPhysMaterialOverride(PhysMat);
        BCRougeMesh->SetPhysMaterialOverride(PhysMat);
        PhysMat->Friction = 0;
    }

    BCRougeMovement = CreateDefaultSubobject <UProjectileMovementComponent>(TEXT("ProjectileMovementComp"));
    BCRougeMovement->InitialSpeed = 800;
    BCRougeMovement->MaxSpeed = 8500;
    BCRougeMovement->Bounciness = 1;
    BCRougeMovement->Friction = 0;
    BCRougeMovement->Velocity = (FVector(0.f, -1.f, 0.f));
    //RootComponent = BCRougeMovement;

    RootComponent = BCRougeMesh;
}

// Called when the game starts or when spawned<br>
void ABCRouge::BeginPlay() 
{
Super::BeginPlay();
//ConstructorHelpers::FObjectFinder&lt;UStaticMeshComponent&gt;MeshRef(TEXT("Game/ThirdPerson/Meshes/CubeMesh.CubeMesh"));
//BCRougeMesh-&gt;SetStaticMesh(MeshRef);

//ConstructorHelpers::FObjectFinder&lt;UStaticMesh&gt;MeshAsset(TEXT("StaticMesh'/Game/CubeMesh.CubeMesh"));
//UStaticMesh* Asset = MeshAsset.Object;

//BCRougeMesh-&gt;SetStaticMesh(Asset);

}

// Called every frame<br>
void ABCRouge::Tick(float DeltaTime) 
{
Super::Tick(DeltaTime);
UMyGameInstance * MyGameInstance = Cast < UMyGameInstance>(UGameplayStatics::GetGameInstance(GetWorld()));
if (MyGameInstance)
{
    //MyGameInstance->PointBalle2++;
}

}

Not sure why you are setting the friction via c++. The material should probably dictate this value inside the physics material

Not getting any errors after adding the nullptr check

I put this but apparently, physMat = nuulptr bcs the physmat don’t appear in the editor and i tried this : GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Red, (“Friction”)); But nothing appeared.

Did you set physMat for the object in the details panel?

The one thing i see in the details panel is " Phys Mat" but not PhysMat as expected.

It’s how Unreal separates camel case in the editor to make it more readable.
Each new capital letter splits the word. It’s the same variable.

Oh nice, so i set it but “Friction” Don’t appear as if PhysMat = nullptr and even if i set this for the ball in game, the one who arrived during game won’t have it set.

It’s not null in my project. Did you set it in the blueprint version of the c++ file or if a pure c++ after it spawns?

well it’s a pure c++ after its spawn, i wanted to make a c++ project so the object that spawns is this c++ object

Hi, sorry for all of this, i have just understand that a project can’t be only in c++ or BP. SO by using c++ to make the actor spawn and BP for the actor, i fix the issue. Last but not least i’ve again a probleme, i want to make a bouncy ball but the ball is losing speed even thought i set friction to 0 and bounciness to 1. Thank you so much

Don’t think it can bounce indefinitely.

Seems all objects lose energy with time. You would probably need to add velocity at points of the bounce to try to emulate it’s perpetual motion.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.