Suggestion for the clarity and visualisation of our suggested projectile velocity

urc_s04_predict_projectile_landing_point

#1

Greetings to everyone who reads this!
I have a suggestion as to how to actually make the suggested projectile velocity visualize itself in a pretty neat manner. All that is required is to put “true” in the bool bDrawDebug option in SuggestProjectileVelocity. That is the very last option.


This is how I’ve done my SuggestedProjectileVelocity function, and the most important thing in here is the very last “true” that is taken in.
If we do it like this, every frame it will start drawing a debug line for us like this:

Enemy tanks are now shown to actually aim at us, and we see the line that we are aiming

Looks somewhat ugly, but what can you do. At least it visualises us what we want to see.


#2

Very useful. Many thanks.


#3

I did mine like this too, though I was unsure what exactly to do for ActorsToIgnore, as it seems to be an out parameter. How exactly did you handle that in yours? Have you set up a variable in your header file which you’ve passed in?


#4

I have just created an empty TArray of actor pointers and wrote it in the method. I didn`t do anything else with it, and there is no need to.


#5

Thanks for clearing that up :slight_smile:


#6

Thanks dear but I dont get why you use UGameplayStatics?:thinking::thinking:


#7

Sorry for the long reply. I have just decided to do it like that before I actually watched the solution. I am quite used to the OOP (Object Oriented Programming) so I just created an object of UGameplayStatics on reflex instead of using it directly to call a method from it. In this case it is unnecesary to do it like this, but if you are going to use UGameplayStatics a lot in a class then you might want to create one in the header, since it might be benificial to have a separate object dedicated to calling things from the UGameplayStatics class instead of having to call everything manually, basicly recreating and destroying the object again and again for no reason. It might hinder your performance. So yeah, I guess that is my reasoning for what I have done.


#8

Hi, I did the same, but my traces come out as parabolas, which should be the case for projectiles moving in two dimensions under the influence of a constant force (gravity), whereas yours look like straight lines to me in your picture.

What I think is going on is that your traces are not straight, but are parabolas with very small curvature, and the reason for this is that your gravity is set to 10 centimeters per second per second (that’s the “10” parameter in your SuggestProjectileVelocity function call), if I have my units right. Meaning your gravity is 100 times smaller than Earth surface gravity (10 meters per second per second, or 1000 cm/s^2). (And also the wrong sign, I think a negative sign is required for gravity to point down). Is that what you intended to do?

I checked inside the source code for GameplayStatics::SuggestProjectileVelocity, and if 0 is given as the parameter for gravity, it uses the world gravity (which, again, I think is -1000 cm/s^2).


#9

My traces also had paraboloid shapes. It is just hard to see because when they are drawn they overlap with each other. When you are using SuggestProjectileVelocity it creates a curve by which a projectile should go in order to reach a point that you tell it, using the force that you are setting. As the force grows stronger, the debug trace will straighten more and more. If the force is raletively small, then the velocity will need to be a bit more curvy to achieve it’s destination with the force that you gave it.


#10

When you are using SuggestProjectileVelocity it creates a curve by which a projectile should go in order to reach a point that you tell it, using the force that you are setting.

Which force are you talking about? SPV assumes that a projectile is moving with a given initial velocity in a constant force field. The only force we set is gravity, and you’re gravity seems to me (again I could be mistaken about the units) to be set to positive ten centimeters per second per second. Which is probably not what most of us are going for (who knows, perhaps your simulation takes place in space where the positive z axis is pointed towards the nearest massive body?).


#11

Yes, sorry, it was not a force but an initial speed. I needed to review a bit what was needed to be passed into the SPV function. I was thinking of physics at that time, you know, the F = m*a stuff. Gravity in this context, I think, is not a force but an acceleration (z axis acceleration that is). Which means that it is not cm/sec (even if it was a force, then the measurement units are Newtons) as you said but cm/sec^2. Don’t take my word for it, I too might be wrong on that one. It was a while since I’ve watched this lecture.


#12

Right, I think that it requests gravity as an acceleration, whose units are indeed cm/second/second (as I said, and which can also be written as cm/sec^2, as you wrote). But, if you pass the float “10” as the parameter for gravity, I think you are specifying a gravitational acceleration of +10 cm/sec^2, meaning your simulated projectiles will accelerate upwards at 1/100 of Earth surface gravity.

Anyway, if it’s working for you, great, and thanks for the discussion.