Referencing outside components

Hi all,
First of all, I apologize for any confusion in my question, either from my terrible English or poor explaination.

My idea is to write a separate scence_component so that when attached to a staticmesh, will act onto that staticmesh (for this case, adding force to it). Itself will also have a static_mesh component, so that during runtime the scene_component itself can interact with the included static_mesh. I call this wheel_component.

Next I created a pawn, with a staticmesh as defaultRoot, then attach wheel_component on to it as children:
StaticMesh
-Wheel_Component1
-Wheel_Component2
In the cpp file of the wheel_component, I have variable to reference the staticmesh like this:


UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components")
        UStaticMeshComponent* rigidbody;
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components")
        UStaticMeshComponent* wheel_mesh;

When creating the parent pawn with visual scripting editor, how can I reference the parent mesh component “rigidbody” and set the mesh for “wheel_mesh”?
If the current plan is not possible, should I change the current wheel_component from scene_component to actor? Then attach “wheel_mesh” as a component? Or what would be the best way to implement my idea?

I was a Unity developer just switched to Unreal due to work requirement. My mindset currently is still heavily based on Unity’s workflow. My plan for this setup is to create a separate wheel component that handles its own force calculation based on the input fed from the parent pawn. It will also handle its own visual movement by modifying the included staticmesh (wheel_mesh). In Unity, this is done by creating new GameObject for each wheel, then attach wheel_component script onto it. The rigidbody is referenced by either search_by_component or drag_drop. Same with wheel_mesh. Also wheel_mesh would be a separate gameObject with mesh component attached.
Thank you guys very much.

If you just want to access components from BP, you can drag the desired component from the upper left(the component-tree box) onto the graph, or search for it by name in the graph. Make sure it is visible to Blueprint.

To set the static mesh of a UStaticMeshComponent, use SetStaticMesh(). You can see more here.

You can achieve the same structure you would use on Unity, and you can also use inheritance to specialize an AActor. Based on your description, derive a class, either in C++ or BP, from AActor, to represent the wheel(equivalent to your GameObject in Unity), then create a wheel_component. Add the component to the AActor derived-class you created, either in C++ or BP. You now have an AActor with a wheel_component. The wheel can have a UStaticMeshComponent if it needs one.

You can access components by their name, both in C++ and BP, they are just variables. You don’t need to look for them, but if you want to, you can use GetComponentByClass().

Keep in mind UE4 makes a clear distinction between a UStaticMeshComponentand a UStaticMesh. Take care not to confuse them.

Let me know if you have any doubt, I am not completely sure what your problem is.

Thanks for the reply.
Sorry for the confusion. I have some screenshot here to clarify.
This is the setup I’m having:
20200218--Copy.png
I’m trying to have 4 Wheel_component updating themselves each tick, then apply force to the Body above.
What I want to ask is here, in the Component categories, where I created StaticMeshComponent to host the meshes.
20200218.png
I want to update the position/rotation of these meshes during tick in the Wheel_component.
I can’t drag/drop the Body component on the left panel to the hosting StaticMeshComponent on the right panel. Should I change the hosting StaticMeshComponent to StaticMesh ? Note that I need to use AddForceAtLocation().
Thank you very much and sorry for the confusion.