Hello, This is my first time posting in this forum so please go easy on me.
I’m making a game which has a bouncing ball in it, I’ve achieved the bounce effect of the ball using the
UProjectileMovementComponent now I want to add radial force on the ball when it overlaps my
when I try to use
MyProjectile->MyProjectileMovementComponent->AddRadialForce() It does nothing… I’ve been digging around the source and found out that the default implementation of
UMovementComponent::AddRadialForce() does nothing as shown here.
And I can’t use
MyProjectile->MyRootComponent->AddRadialForce() because my projectile is not simulating physics…
Is there a way to add radial force to an actor which uses
Or should I code my own
Hi. Place radial force component in your Vacuum Actor, set Radius and Impulse Strength strong enough to have an influence on your ball actor. and handle overlap event with radial force component - fire impulse function call !
add more force and try again and it will work . sorry can answer only tomorrow
Hello, Thank you for responding.
I’ve tried this but nothing happened… And to be sure, I’ve placed a ball simulating physics next to my bouncing ball and your solution worked for it but did not affect my bouncing ball.
I am thinking of creating a custom component inherited from
UProjectileMovementComponent and override the
AddRadialForce() then, When I call the function I’ll get the
Vacuum location and use it as the origin of the force. I hope this will work…
If you have any other ideas please comment them down
I’ve tried it but still, nothing…
void ABlackHole::Tick(float DeltaSeconds)
for (UPrimitiveComponent* Component : Components)
if (Component && Component->IsSimulatingPhysics())
FVector DirectionToAttract = GetActorLocation() - Component->GetComponentLocation();
FVector Force = DirectionToAttract * ForceStrength;
/** REPLACE TO HEADER */
/* attractive sphere */
// UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components", meta = (AllowPrivateAccess = "true"))
// class USphereComponent* AttractiveSphere;
/** the force strength to attract physics objects */
// UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Config", meta = (AllowPrivateAccess = "true"))
// float ForceStrength = 2500.f;
BP version of black hole with radial force component
I don’t know what is “a bouncing ball” is a thing in your project, but to use my way it needs something that simulates physics to work. For instance, static mesh component of bouncing ball actor…
Hello, Thank you for your anwser.
The scenario I want to achieve is to make my ball get effected by the radial force of the vacuum.
Look, What is the main problem is that my
Projectile is not simulating physics… In your answer here you made a check whether if the overlapping component is simulating physics or not
if (Component && Component->IsSimulatingPhysics()). Here the problem is that the
UProjetileMovementComponent replace the root component & will only take affect if the replaced component is not simulating physics (Hence So it will never execute this if block) and it is a collision component. Furthermore, if the replaced component is simulating physics then it will only take affect Once “From when the
Projectile is spawned, till the first event occurs which needs physics to operate on”.
For example: " If I lunched the ‘simulating physics projectile’ by changing the velocity of the
UProjectileMovementComponent it will move using
UProjectileMovementComponent but when it hit something the
UProjectileMovementComponent is deactivated and the physics take place from there" And when this happens, the
Projectile will no longer bounce…
- I see what you are trying to say,
If I make the
StaticMesh as child and enable its physics so it will be effected by the force.Well It will But, the only thing will be effected is the
StaticMesh and not the root.
This is a problem because the
StaticMesh will be moved while the replaced component (RootComponent) will stay at the same position.
If I set the updated component to the mesh and disable its physics then enable the root’s component physics… It will be absorbed but wont bounce cause the
UProjectileMovementComponent only works on collision component…
If I have any wrong knowledge please correct me.
Thanx in advance.
Hey, Thank you it worked! I really appreciate it.
It didn’t have the same effect I was looking for but I think I can live with that
I made some tryes by myself and its seems to physics and projectile movement component isn’t compatible. Engine force us to use only one thing at the same time… You can dive deep in this direction. But I have some idea to force your vacuum works and it will be very simple solution. You can try something like this. Make a USphereComponent for Vacuum actor (it will be vacuum influence border). Whenever your bouncing ball overlaps this sphere collider Mark your projectile movement component as Homing Projectile and set Homing Target component to the root component of the Vacuum actor (also set Homing acceleration magnitude to sensible default value)
and reverse it back whenever vacuum intended to stop working according to your game mechanic
sphere collision is root of vacuum