0
\$\begingroup\$

Here is the code and very simple. I can see the object in the blue print and has nothing except the object itself. so all the issue should be on the C++ code.

UCLASS(config=Game)
class APiramidShootingProjectile : public AActor
{
    GENERATED_BODY()

    /** Sphere collision component */
    UPROPERTY(VisibleDefaultsOnly, Category=Projectile)
    class USphereComponent* CollisionComp;

    /** Projectile movement component */
    UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Movement, meta = (AllowPrivateAccess = "true"))
    class UProjectileMovementComponent* ProjectileMovement;

public:
    APiramidShootingProjectile();

    /** called when projectile hits something */
    UFUNCTION()
    void OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit);

    /** Returns CollisionComp subobject **/
    FORCEINLINE class USphereComponent* GetCollisionComp() const { return CollisionComp; }
    /** Returns ProjectileMovement subobject **/
    FORCEINLINE class UProjectileMovementComponent* GetProjectileMovement() const { return ProjectileMovement; }

};

and the C++ (without the hit portion)

APiramidShootingProjectile::APiramidShootingProjectile() 
{
/*  SetRemoteRoleForBackwardsCompat(ROLE_SimulatedProxy);
    bReplicates = true;
    SetReplicatingMovement(true);
    */
    // Use a sphere as a simple collision representation
    CollisionComp = CreateDefaultSubobject<USphereComponent>(TEXT("SphereComp"));
    CollisionComp->InitSphereRadius(5.0f);
    CollisionComp->BodyInstance.SetCollisionProfileName("Projectile");
    CollisionComp->OnComponentHit.AddDynamic(this, &APiramidShootingProjectile::OnHit);     // set up a notification for when this component hits something blocking

    // Players can't walk on it
    CollisionComp->SetWalkableSlopeOverride(FWalkableSlopeOverride(WalkableSlope_Unwalkable, 0.f));
    CollisionComp->CanCharacterStepUpOn = ECB_No;

    // Set as root component
    RootComponent = CollisionComp;

    // Use a ProjectileMovementComponent to govern this projectile's movement
    ProjectileMovement = CreateDefaultSubobject<UProjectileMovementComponent>(TEXT("ProjectileComp"));
    ProjectileMovement->UpdatedComponent = CollisionComp;
    ProjectileMovement->InitialSpeed = 3000.f;
    ProjectileMovement->MaxSpeed = 3000.f;
    ProjectileMovement->bRotationFollowsVelocity = true;
    ProjectileMovement->bShouldBounce = true;

    // Die after 3 seconds by default
    InitialLifeSpan = 1000.0f;

    //For Multiplayer
    //bReplicates = true;
}

so here all that should be shown is created, but nothing shows, even so when i aim something the hit function works and works as it should, so really not understanding what its happening. I am new to this and extremely frustrated so please answer as soon as possible.

\$\endgroup\$
2
  • \$\begingroup\$ I don't see where you add visual components (e.g. a mesh) to the projectile. Collision itself provides physics only, no visuals. \$\endgroup\$ Mar 24, 2021 at 15:24
  • \$\begingroup\$ thanks that was the problem, i noticed that it was easier to do it by the BL and solvedi t that way \$\endgroup\$ Apr 5, 2021 at 0:40

0

You must log in to answer this question.

Browse other questions tagged .