you want thing like ricochet ? if you use movement component for your projectile, it have value for you if you want bullet bounce.
ok, then when hit you need calculate the next velocity of your bullet then just AddImpulse with true for velocity change.
Hi. My projectile must continue its movement after hit event at some conditions. How to relaunch it if it has stopped?
Yes you are right. I know about bounce params, but in my case bullet should bounce at some angles and pierce the object at other angles
Not working. Projectile stops anyway
Hi FiftyStars,
Here is a tutorial on how to create a ricocheting line trace. Even if it canāt be adapted to your projectile, it may give you some ideas.
Hi, i know how to calculate trajectory. I dont understand how to re launch projectile after it was stopped by the wall
Hi,
ProjectileMovementComponent has category Projectile Bounces. You should check property āShouldBounceā to continue projectile moving. In addition, you can use Bounciness parameter to control bounce direction or you can use Event Hit to update projectile moving direction. If ShouldBounce is unchecked after first hit, projectile simulation will stop.
Hope it helps!
Hey, Iām trying to do something similar to you and I have to ways so far but none of them are perfect.
The first one requires physics so you need to enable them on your collision component (check Simulate Physics). This allows you to add impulses and force to your object. The problem is that your object will spin around so if you use get control rotation and get forward vector it might not have the results you want. I still donāt know how to fix that so if anybody has an idea Iāll be really interested in hearing it.
The second solution I tried didnāt involve physics. I guess that you have a Projectile Movement component in your projectile. Just get that and call set velocity. As for the value, just get the Control Rotation ā Get Forward Vector and multiply that by some float value and then plug it into set velocity.
Hi. Iāve āsolvedā my problem by creating projectile without projectile movement component. Implementing movement is easy. Bouncing - a bit harder but still real. The best thing is that i can manually start/stop its movement.
Could you elaborate a bit on how you did this? Thank you.
I appreciate the answer, but I am wondering if you can expand exactly on how you came up with this solution. Im guessing each frame you add an impulse in the forward vector? How did you implement the bouncing and gravity? Thank you in advance
I dont know how āgoodā it was, but i have just created my own projectile system. A bit of gravity, a bit of bouncing, a bit of acceleration/deceleration and some other things to make it similar to projectile movement component with a bit different behaviour
Yes, it is attached to tick event.
Its just physics. Its hard for me to answer to you, because english is not my native =D This is simple physics + geometry
Iāve found a solution to do this in blueprints only.
-
Make actor with ProjectileMovementComponent AS VARIABLE
-
Add ProjectileMovementComponent in construction script
-
Detect hit you want to ignore - set ignores for components of both actors
-
Destroy ProjectileMovementComponent and add a new one like this:
Note that ProjectileMovementComponent should have autoactivate set true for this to work smoothly
This is exactly what I was looking for. Thanks.
Theres another option to do this if you donāt want to destroy the component, but its a bit of a hack. In cpp code i found that on hit projectile component has active component variable cleared. You can reinitialize this with setactivecomponent blueprint block. After this you only need to set the velocity to make it fly.
Hello,
I have done this myself, it is quite complicated to make it very good, I followed a tuturial from a youtuber called MipGames, and i think that tutarial is almost perfect. Link down bellow.
Part 1: Unreal Engine Tutorial - Bullet Physics / Projectile Physics and Penetration Part 1/5 - YouTube
Part 2: Unreal Engine Tutorial - Bullet Physics / Projectile Physics and Penetration Part 2/5 - YouTube
Part 3: Unreal Engine Tutorial - Bullet Physics/Projectile Physics and Penetration Part 3/5 - YouTube
Part 4: Unreal Engine Tutorial - Projectile Physics part 4/5 - YouTube
Part 5: Unreal Engine Tutorial - Projectile Physics part 5/5 - YouTube
Digging through the code, I found the following function:
void UProjectileMovementComponent::StopSimulating(const FHitResult& HitResult)
{
SetUpdatedComponent(NULL);
Velocity = FVector::ZeroVector;
OnProjectileStop.Broadcast(HitResult);
}
So all you have to do to restart a ProjectileMovementComponent should be to reset the UpdatedComponent and Velocity. Itās probably a good idea to call Activate on the ProjectileMovementComponent as well to make sure the ProjectileMovementComponentās Tick is still enabled.
In case anyone needs different approach, the way our team did was to make a projectile overlap an obstacle. If itās supposed to bounce, change normalized vector of the projectile when OnBeginOverlap fires. If itās supposed to penetrate, just let it go. If itās supposed to be blocked, use Stop Movement Immediately.