#[Tip] Making your field system Actor in cpp
9 messages · Page 1 of 1 (latest)
[Tip] Making your field system Actor in cpp
What is MFieldActorClass ?
Any variable on this script that starts with an M means it’s a member variable of the class
E.g Ustaticcomponent object will be names as MCharacter mesh …. Some developers use it to distinguish member variables and temporary once
Thank you very much for it. it's not difficult and much better than blueprinting
I used the above screenshots to write this C++ implementation of the force field. Hopefully this will make it easier for somebody else who is trying to do the same.
In AWeapon::BeginPlay() I have this to create an instance:
if (auto* pWorld = GetWorld()) {
if (auto* pClass = AWeaponField::StaticClass()) {
this->pFieldSystemActor = pWorld->SpawnActor<AWeaponField>(pClass);
if (this->pFieldSystemActor) {
this->pFieldSystemActor->AttachToActor(this,
FAttachmentTransformRules::SnapToTargetIncludingScale);
this->pFieldSystemActor->SetOwner(this);
}
}
}