0
\$\begingroup\$

I've created a blueprint (well, two of them, as a test since the first one wasn't working right) with an sphere component around a mesh, as in the picture:

Blueprint editor

As you can see, the mesh is well placed inside the collision component outer grid lines, but when I place this blueprint in the editor the mesh appears displaced from the grid:

Unreal Engine editor

I've checked this is not a merely visual bug of the editor; the collision component is really at different coordinates than the mesh, making all kind of strange collisions and side effects. However, I fail to see why is this happening, or what can I do to solve it. The blueprint is based on a custom C++ class, but I'm not making anything related to position in there. I paste the full code of that class:

#include "FPSBall.h"

// Sets default values
AFPSBall::AFPSBall(const FObjectInitializer& ObjectInitializer)
{
    // Crear una malla
    MeshComp = ObjectInitializer.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("Mesh"));
    MeshComp->SetMobility(EComponentMobility::Movable);

    // Crear un component esfèric per a les colisions
    CollisionComp = ObjectInitializer.CreateDefaultSubobject<USphereComponent>(this, TEXT("Envolvent esferic"));
    CollisionComp->BodyInstance.SetCollisionProfileName("Pilota");
    RootComponent = CollisionComp;

    // Valors inicials de transformació
    Velocitat = 0.0f;
    Direccio = FVector(1, 2, 3);
    Rotacio = FRotator(3, 2, 1);
}

void AFPSBall::Shoot(float velocitat, FVector a_on, FRotator spin, FVector hit)
{
    Velocitat = velocitat;
    Direccio = a_on;
    Rotacio = spin;
    CollisionComp->AddImpulse(Direccio * Velocitat);
}

Can anyone point me towards a solution? I could try to fix things in the class constructor, but I fail to see why this is not working out-of-the-box and I don't want to try fixing things that shouldn't be broken to start with.

\$\endgroup\$
0
\$\begingroup\$

Make sure your mesh ignores collisions. Or atleast it ignores the collision component by setting channels to ignore eachother.

\$\endgroup\$
  • \$\begingroup\$ I've set the "Collision presets" on the mesh to "NoCollision" and recompiled, but no changes. :( \$\endgroup\$ – Rekesoft Apr 23 at 19:25
  • \$\begingroup\$ Make sure it has no collisions also in BP, \$\endgroup\$ – ColdSteel Apr 23 at 23:05
  • \$\begingroup\$ Make sure you dont use hotreload, this feature is bugy and breaks blueprints (in case you are not on 4.22), make sure you close the editor compile in VS and then open the editor, in case the bp is already broken by hotreload you will have to recreate it. \$\endgroup\$ – ColdSteel Apr 23 at 23:06
  • \$\begingroup\$ Also check that no sphere or mesh dont affect navigation \$\endgroup\$ – ColdSteel Apr 23 at 23:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.