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).