I have a missile projectile that i want to control after it is spawned. Can anyone help me out?
Hi,
You are correct that only 1 BP actor can be possesed at the time. However, if you are attempting to make a homing missile that will track targets without having to maunally guide it. You could simply make your missile a simple AI flying pawn. Then use a nav mesh to give it simple move to commands. Alternatively, you can use a system similar to the one used in the Turned Based Strategy template available free in the market, to use force to move your pawn across the stage without needing a navemesh or even a movement component on it. I can give you more details on either if this is what you are trying to do. If not let me know and I might be able to help you make a mouse guided missile at the cost of abandoning your default pawn while you pilot it.
I´ve added the mouse controls of a vehicle i am working on, still right after the projectile is fired, the mouse controls do not change the tragectory of it. I´m starting to think that it cannot be done and only one BP actor can be possesed at a time, can someone please correct me if i´m wrong?
Hey Cross1013,
Thanks for the reply, i toke a look to homing missiles tutorial but is not what i am looking for, the projectile will be “wire guided” until its collision hits something.
M9113 wiki - 9M113 Konkurs - Wikipedia
I found a video to represent my goal, is no more than this - - YouTube at 0:14.
I have the same vehicle, same projectile, how to drive the projectile is the question. I think that abandoning the pawn to control of the projectile may be a good idea if there is a chance to return to the pawn after the projectile (actor) is destroyed.
perhaps just get the control inputs of your Pawn, then feed them as steering inputs to your projectile… this way you’d be able to control both actors simultaneously
Just launch the projectile using your desired velocity, don’t set it to homing …
In your projectile’s event graph, Get Player Pawn or Get Player Controller, get the control input values (maybe pitch and yaw, I guess you are using mouse control), use these inputs in your projectile BP (multiplied by a scalar) to add to world rotation, you might need to smooth the inputs using an interp node.
So i still trying to get this to work, ANorthStar, thank for your input. I´ve added the control nodes from my pawn, which i´ve done before and added the playercontrol node this following way:
The “Box” is a collision that i´m trying to drive, the projectile still going forward, no left or right movement is seen. Maybe i should add something in the pawn part too?
… for simplicity, initially, I’d run this on Tick in your projectile… in BeginPlay just get a reference to your Player Pawn and promote to a variable… on tick, I’d get the Pitch / Yaw input axis magnitudes (assuming you are using mouse inputs), and apply them (with a scalar) to Add World Rotation of your projectile
Quick question, is this how you reference a pawn? The variables i did so far are floats and booleans,
I hope what i am asking won’t be too much sand for my wagon.
It’s ok to ask… it took me ages to get my head around getting references and casting… it seemed like witchcraft for ages… here you go. Just cast to whatever your custom player character’s class is (my custom class is called PlayerCharacter… just to clear up the possible confusion). Once you have a reference to your Player Character BP (or player controller BP) just get the mouse inputs, and in your Projectile BP, using Add World Rotation… apply to your projectile rotation…
Thanks for your input, unfortunately i still did not get the result i want using your bp. I´ve burned out regarding this question but if i ever make it working i´ll defenetly post my solution for the sake of other also looking for this. Thanks again and good day.
You need to update it’s velocity.
Eg this will apply a = 20 m/s /s on world Z axis which will result in a > g (which is 9.8) and will make the projectile fly above instead of falling to gravity.
To control this with keyboard, you need to create an event that will update velocity according to your needs (how much, in what direction, etc) on your projectile and call it when input is received (when spawning projectile, store its reference at your pawn and in pawn keyboard event call event on the projectile).
I use interpolating rotation of the projectile so it would look onto the target point.
Interpolating rotator is my own function
Interpolating angle
Normalizing degrees to [-180, 180]:
double UCoreExtendingFunctionLibrary::DegreesToStandardized(double Degrees)
{
Degrees = UKismetMathLibrary::GenericPercent_FloatFloat(Degrees, 360.0f);
// Holy Emperor knows how this works, but we are definitely in [-360, 360]
if (Degrees > 180.0f)
{
// We got into (180, 360], will go to (-180, 0]
return Degrees - 360.0f;
}
if (Degrees < -180.0f)
{
// We got into [-360, -180), will go to [0, 180)
return Degrees + 360.0f;
}
// We got into [-180, 180]
return Degrees;
}
Update Target Point is called in my gameplay ability in my case, but you can place it where you want as a result of tracing.
Another way is the move a scene component and have the PMC home onto and orient towards said comp; it can do that out of the box. You’d cut down on all the math and extra ticking.
You’d, potentially, give up a bit of control. But it can be fun to re-invent the wheel.