In Geometry Script How to change Origin of Dynamic Generated Mesh Actor's Mesh Component ?

I wan to Change origin of cone generated using geometry script in which I am using Dynamic Generated Mesh Actor and I want to change cone origin from Base to Tip of cone ??



Blueprint Approach

  1. Generate Cone Mesh: Use Blueprint nodes to generate your cone.
  2. Adjust Origin: Use the Set Relative Location node to move the mesh after generation. You will need to calculate the offset based on the height of the cone.
  • Get the Cone Dimensions: If you have access to the dimensions of the cone, you can use them to calculate the offset.
  • Apply the Offset: Use the Set Relative Location node to adjust the position so that the tip of the cone is at the desired origin.For example, if your cone’s height is known, you can create a vector offset and apply it to the cone’s location.

C++ Approach

  1. Generate Cone Mesh: Use the appropriate functions from UGeometryScript to generate the cone mesh.
  2. Adjust Origin: After the cone is generated, you need to adjust its position. For a cone, this usually involves translating it by the height of the cone so that the tip is at the origin.Here is a rough example of how you might adjust the origin in C++:
UStaticMesh* ConeMesh = /* Your generated cone mesh */;
FVector ConeDimensions = /* Calculate or get the dimensions of the cone */;
FVector NewOriginOffset = FVector(0.0f, 0.0f, -ConeDimensions.Z / 2.0f);

// Assuming MeshComponent is your mesh component for the dynamic mesh
UStaticMeshComponent* MeshComponent = /* Your mesh component */;
MeshComponent->SetRelativeLocation(MeshComponent->GetRelativeLocation() + NewOriginOffset);

Ensure you replace ConeDimensions.Z with the actual height of the cone.