4.12 Transition Guide

I can’t seem to get AddDynamic to work. It seems that is is compiling against 4.12 source, but the signature is wrong?

Here is the signature that I see when I go to the declaration of it:



// Delegate signatures
DECLARE_DYNAMIC_MULTICAST_DELEGATE_FiveParams( FTakeAnyDamageSignature, AActor*, DamagedActor, float, Damage, const class UDamageType*, DamageType, class AController*, InstigatedBy, AActor*, DamageCauser );
DECLARE_DYNAMIC_MULTICAST_DELEGATE_NineParams( FTakePointDamageSignature, AActor*, DamagedActor, float, Damage, class AController*, InstigatedBy, FVector, HitLocation, class UPrimitiveComponent*, FHitComponent, FName, BoneName, FVector, ShotFromDirection, const class UDamageType*, DamageType, AActor*, DamageCauser );
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams( FActorBeginOverlapSignature, AActor*, OverlappedActor, AActor*, OtherActor );
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams( FActorEndOverlapSignature, AActor*, OverlappedActor, AActor*, OtherActor );
DECLARE_DYNAMIC_MULTICAST_DELEGATE_FourParams( FActorHitSignature, AActor*, SelfActor, AActor*, OtherActor, FVector, NormalImpulse, const FHitResult&, Hit );


That’s all I can see. My function for overlap is the following:



void OnOverlapBegin(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor);


I added the extra parameter, but no luck. I have also cleared the intermediate and binary directories and built from scratch.

Any ideas?

I had a hard time with this when upgrading my project as I could not find documentation on this. I also don’t know how to view a signature for a delegate even though I thought I knew c++.

Rama gave the correct information but the example was applied to component overlap. The new argument added is the pointer to the object that is being tested for overlap, because you are using Actor overlap, your pointer variable must be of type Actor and not UPrimitiveComponent. The code below should fix your issue as it had for me:

void OnOverlapBegin(AActor* OverlappedComponent, AActor* OtherActor);

Edit:
This was confirmed to be a legit bug in the 4.12 release, hopefully fixed next update.

Sorry there’s really two sets of examples:

//Actor.h



DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams( FActorBeginOverlapSignature, AActor*, OverlappedActor, AActor*, OtherActor );
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams( FActorEndOverlapSignature, AActor*, OverlappedActor, AActor*, OtherActor );


//PrimitiveComponent.h



/** Delegate for notification of start of overlap with a specific component */
DECLARE_DYNAMIC_MULTICAST_DELEGATE_SixParams( FComponentBeginOverlapSignature, UPrimitiveComponent*, OverlappedComponent, AActor*, OtherActor, UPrimitiveComponent*, OtherComp, int32, OtherBodyIndex, bool, bFromSweep, const FHitResult &, SweepResult);

/** Delegate for notification of end of overlap with a specific component */
DECLARE_DYNAMIC_MULTICAST_DELEGATE_FourParams( FComponentEndOverlapSignature, UPrimitiveComponent*, OverlappedComponent, AActor*, OtherActor, UPrimitiveComponent*, OtherComp, int32, OtherBodyIndex);


Simply remove the signature and the commas and you end up with the function parameters you need to include for each respective type:

For An Actor



UFUNCTION()
void YourFun(AActor* OverlappedActor, AActor* OtherActor) ;


For a component



UFUNCTION()
void YourFunc(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult);


:heart:

Rama

Thanks for letting us know @Juice-Tin!

Makes all our lives easier when we share this kind of info :slight_smile:

:slight_smile:

Rama

Hi,

In the XMPP module.h they add 2 new function: OnXmppRoomCreated && OnXmppRoomConfigured.
Now I’m getting a compilation error because FXmppRoomId is not known. What should we add as an header in order to use this properly?

for now, I add typedef FString FXmppRoomId; before the header, but that’s dirty coding.

Thanks for your feedback.

Woah, just finished updating my code to fit the latest signatures. Quite some work.

Thanks for all the information guys; especially the way to use the AttachmentRules was a major help in actually getting the game to compile correctly. One thing I am wondering about though; am I right into assuming that “KeepRelativeLocation” is the same as the keep relative offset thing from before?

FActorDestroyedSignature delegate now requires the pointer to the destroyed actor in 4.12



DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FActorDestroyedSignature, AActor*, DestroyedActor );


So, I’m getting this error:
error C2440: ‘<function-style-cast>’: cannot convert from ‘FPackedNormal’ to ‘FVector’

How can I make this conversion, now?

You need to show us the offending code. FPackedNormal looks liks something you’ve made?

FPackedNormal is a built in struct.

Here’s the code that used to work though. TangentZ and TangentX are FPackedNormals.

FVector GetTangentY()
{
return (FVector(TangentZ) ^ FVector(TangentX)) * ((float)TangentZ.Vector.W / 127.5f - 1.0f);
}

Edit:
Hrmmm… Looking at it now, putting a float conversion in front of each value of the FPackedNormal and then making an FVector from that might fix it…

Like the following (which might not be exactly right as I’m doing it by guessing)

FVector((float)TangentZ.Vector.X, (float)TangentZ.Vector.Y, (float)TangentZ.Vector.Z)

Will check when I get home.

Just going to manually convert the FPackedNormal to an FVector:

Alright, so would converting the FPackedNormal this way work mathematically?:


FVector TangentZVector((float)TangentZ.Vector.X / 128.0f, (float)TangentZ.Vector.Y / 128.0f, (float)TangentZ.Vector.Z / 128.0f);

Each entry of the packed normal is a normalized, and the entries are four packed int8s into an int32. So dividing by 128 would make it into a proper float, right?

Another 4.12 issue comes from FDataTableRowHandle:

error C2780: ‘T *FDataTableRowHandle::GetRow(const FString &) const’: expects 1 arguments - 0 provided

Here is my reference code:


LevelUpDataHandle.RowName = *FString::FromInt(Level + 1); // +1 to find next level conditions
const FLevelUpData* LocalLevelData = LevelUpDataHandle.GetRow<FLevelUpData>());

Looking at the template in Unreal for the GetRow function shows this:

T* GetRow(const FString& ContextString) const

It needs a “contextString” argument? What exactly would that be? Is it just the FString::FromInt(Level+1) I have as the RowName? I looked at the Template Function, and it uses the FindRow Template, and it seems like the ContextString just exists to throw a warning in the UE_LOG. Is that correct?

Yes this is also my understanding. It will help you to debug in case any warning is raised.
Useful if you are using a lot of datatable ^^

Cool.

So, as far as FPackedNormal goes, it actually uses a uint8. Because of that the fix I posted earlier should be:


FVector TangentZVector((float)TangentZ.Vector.X / 127.5f - 1.0f, (float)TangentZ.Vector.Y / 127.5f - 1.0f, (float)TangentZ.Vector.Z / 127.5f - 1.0f);

That brings the code into -1,1] properly.

And it also looks like a couple of new items have been added to to its struct:


void operator=(const FVector4& InVector);
operator FVector4() const;

So, when I call


FVector Test(SomeFPackedNormal);

I get this error thrown up:


error C2668: 'FVector::FVector': ambiguous call to overloaded function
note: could be 'FVector::FVector(FVector &&)'
note: or       'FVector::FVector(const FVector &)'
note: or       'FVector::FVector(EForceInit)'
note: or       'FVector::FVector(FIntPoint)'
note: or       'FVector::FVector(FIntVector)'
note: or       'FVector::FVector(const FLinearColor &)'
note: or       'FVector::FVector(const FVector4 &)'
 note: or       'FVector::FVector(float)'
 note: while trying to match the argument list '(FPackedNormal)'
error C2668: 'FVector::FVector': ambiguous call to overloaded function
 note: could be 'FVector::FVector(FVector &&)'
 note: or       'FVector::FVector(const FVector &)'
 note: or       'FVector::FVector(EForceInit)'
 note: or       'FVector::FVector(FIntPoint)'
 note: or       'FVector::FVector(FIntVector)'
 note: or       'FVector::FVector(const FVector4 &)'
 note: or       'FVector::FVector(float)'
 note: while trying to match the argument list '(FPackedNormal)'

This was also not the case before, and is obviously the same problem as I posted earlier, just with a bit more context. So, it seems like the new equality overloads make it unsure whether to convert to FVector or FVector4?

Am I doing something wrong still?

Hi Guys, I seriously need your help… I’ve already posted on the AnswerHub :

but unfortunately the question is already closed (just covering the case where you have your own custom onlinesubsystem)

Basically you can reproduce this just taking a ShooterGame from 4.9 to 4.12, I’ve tried to port my project to 4.11 and it works, is just when I port the project to 4.12 that it fail to package.

BTW is just me hitting this? (apart the few guys in that thread)

Thanks in advance!

For me it worked with the component one. I added the extra parameter but now


BaseCollisionComponent->OnComponentBeginOverlap.AddDynamic(this, &ATeleportPoint::BeginOverlap);

does no longer work. The error message is

Error C2664 “void TBaseDynamicMulticastDelegate<FWeakObjectPtr,void,UPrimitiveComponent *,AActor *,UPrimitiveComponent *,int32,bool,const FHitResult &>::__Internal_AddDynamic<ATeleportPoint>(UserClass ,void (__cdecl ATeleportPoint:: )(UPrimitiveComponent *,AActor *,UPrimitiveComponent ,int32,bool,const FHitResult &),FName)" : Conversion of argument 2 of "void (__cdecl ATeleportPoint:: )(AActor *,AActor )" in "void (__cdecl ATeleportPoint:: )(UPrimitiveComponent *,AActor *,UPrimitiveComponent *,int32,bool,const FHitResult &)” not possible

What am I supposed to do to fix this?

It has some performance problem on AttachTo in 4.12

I use AttachTo in my code, it works fine until I update Engine to 4.12. I change to use SetupAttachment,but it cost too much frametime in tick. So, I revert to use AttachTo,but it still cost too much frametime in tick. I’m confused about this. Haven’t you got this problem?

Any answers? I am running into the same problem.

This is the function signature:
UFUNCTION()
void MyOnBeginOverlap(AActor* OverlappedActor, AActor* OtherActor);

This is the binding:
OnActorBeginOverlap.AddDynamic(this, &AHelloSphere::MyOnBeginOverlap);

It is giving me all kinds of errors (such as the one above) and then I am being told that the call too “AddDynamic” doesn’t match the signature of “__Internal_AddDynamic” etc.

Any help would be greatly appreciated.

I finally was able to fix my problem. It was my own fault. I mixed up the order of the parameters OtherActor and OtherComp. Always be careful when you’re working with code someone else wrote! :smiley:

To attach the weapon to the hand correctly, change the AShooterWeapon::AttachMeshToPawn() function to use a new attachment rule “SnapToTarget”. By default it will attach relative, which seems to be relative to the Mesh1P instead of the attachment point.