Radius of sphere not chaing with InitSphereRadius/SetSphereRadius

(Third time I had to post this since it keeps getting ignored)

When I start an FPS 3D C++ starting project I attempt to modify the sphere radius of the projectile in this line of code


CollisionComp->InitSphereRadius(105.0f);

I also tried


CollisionComp->SetSphereRadius(1000.0f);

But it is not changing the size, I can change the speed of the projectile and the life span but for some reason not the radius. I thought this could be a glitch and tried to make a new project but that did not work either. bVisible is set to its default value so I don’t think that has anything to do with it. I am aware that this is a strange issue :frowning:

CollisionComp is the (by default) invisible sphere component that is used for simulating the physics of your projectile. Changing the radius of that sphere will not change the size of the yellow mesh. I don’t have access to my UE4 machine right now, so I don’t know the exact hierarchy and component names of the Projectile class, but you should try scaling the mesh too. Something like ProjectileMesh->SetRelativeScale3D(FVector(2,2,2)).

Interesting, This is what I thought might have been happening. I could have sworn in the past I have changed this value and it changed the mesh size as-well although maby I’m mistaken.

Update: Yep that fixed it. Here is the code I put in the constructor


this->SetActorScale3D(FVector(5, 5, 5));

Hi Katianie,

Please refrain from creating multiple threads with the same title and questions, if you must bump your thread for an answer you’re allowed to do so every four days. This ensures that everybody has equal opportunity to get an answer to their questions. If you don’t get an answer straight away, please be more patient or try posting on the AnswerHub

I have closed & deleted the duplicate threads.

Thanks.

On Topic: The reason you aren’t changing the size of the Yellow Sphere with SetSphereRadius() or InitSphereRadius(), is because the yellow sphere is a StaticMesh, and a different component.

Ah, yes, that’s even better then what I suggested.

Also, you can try asking on the IRC channel too, when you have an issue.

The projectile spawned is actually a Blueprint that derives from the C++ class. It’s possible the BP (Blueprints/FirstPersonProjectile) is overriding the size, so your change in C++ is not having any effect.

Is there a way to disable the blueprints from doing that since I want a C++ project and not a blueprint project?

Like James said ProjectileBP is overriding the values setted in parent class , you can make your change after your projectile is fired.
here is a simple solution


AMyProject7Projectile* FiredProj = World->SpawnActor<AMyProject7Projectile>(ProjectileClass, SpawnLocation, SpawnRotation);
FiredProj->GetCollisionComp()->SetSphereRadius(100.0f);

Thanks! That’s actually exactly what I ended up doing but I was not sure if it is good practice / makes sense to set the radius right after it has been spawned.

Most of our internal projects use a combination of C++ and BP. There are certain things that are just easier and more robust in BP (e.g. hooking up assets) and that is pretty much what we do in that template. More recent templates do eschew BP completely and set everything (including assets) via C++, so you could look at those and eliminate the BP totally if you wanted.