Search code examples
c++unreal-engine4

Make script in Unity to Unreal


Im new to Unreal. I tried to follow the tutorial into making A* pathfinding: https://www.youtube.com/watch?v=nhiFx28e7JY&t=1252s&ab_channel=SebastianLague

I don't really know how to change the script made in Unity to Unreal.

UnityScript

public class Node {
    
    public bool walkable;
    public Vector3 worldPosition;
    
    public Node(bool _walkable, Vector3 _worldPos) {
        walkable = _walkable;
        worldPosition = _worldPos;
    }
}

My UnrealScript:

USTRUCT(BlueprintType)
struct FAS_Node
{
    GENERATED_USTRUCT_BODY()

    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category= "Nodes")
    FVector worldPosition;

    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category= "Nodes")
    bool walkable;

    Node(bool _walkable, FVector _worldPos){
        walkable = _walkable;
        worldPosition = _worldPos;
    }
};

it return error saying Node doesnt have return type


Solution

  • I guess you cannot create constructors with parameters in such way in UE4. Try define a default constructor. If you really need to pass parameters to it - check ObjectInitializer constructor here: https://ikrima.dev/ue4guide/engine-programming/uobjects/new-uobject-allocation-flow/