Hi,
Is there a way to define a circle under the player character with the center always the player location?
I want to create a circle below the player so that an AI can throw an object within the circle on a random point in the circle, I do know how to find that random spot on the circle whereas I don’t know how to define that circle underneath the player with the dynamic radius so that the accuracy can be more precise or less accurate, therefore, to tell the AI to aim towards that circle.
So you want that circle to be visible under player, or only in code for AI to know where circle is?
For AI its hard to give you solution because you may be using blueprints, or blackboards.
However you can work on throwing item at some target for now. Also I cannot hep here, you did not even give info if you are using physics or projectile or own code there.
So tl/dr:
- do you want to see that circle around player? or it is only imaginary one for code needs.
- what type of AI are you using? Blackboard or blueprint or something from marketplace?
- what type of objects they are, physics, with projectile movement or your own calculations?
Not sure (I am guessing what you need) but this may help:
Oh, you should make that random stream only once and pass it as parameter to this function, else it will always roll same vector/point.
Hello, apologies for my late response.
The circle is imaginary as you said and I only need It for the AI to be able to hit a random spot in the circle, I was able to find a solution to how to generate a random point in the circle, but I don’t know how to define the circle under the player so that those random spots will appear there.
as you can see in the picture;
first, I calculated the radius of the circle based on the angle of the projectile when It gets fired.
second, based on the radius I calculated a random point within the circle.
and I repeat the whole thing based on a “for Loop” which gets the number of shots as its max index.
I’ve used this tutorial if You want to check It out for yourself;
I’ve been using Blueprints for this project and specifically for the AI, I’ve been using behavior tree and also the EQS.
both sort of, I’ve created an actor that has a " projectile movement component " implemented on
as you can see I want to use a " predict projectile path by trace channel " function to determine the landing spot, but the problem is I don’t know how to calculate the trajectory of the projectile based on this function that I mentioned so It hits that random spot on the circle.
so in actuality, there are two issues that I’m trying to wrap my head around;
1: how do I define the circle under the player so that based on my calculations random points appear in the circle.
2: how do I calculate the trajectory of my projectile so It hits the spot.
apologies if I’m not making sense enough, since English is not my native tongue.
I have a question
How do you calculate the center of your circle so that you could feed it to this function?
Here is another take on getting random point in circle around player:
Random point is first calculated around [0,0,0]
To do this, you take FORWARD vector, and rotate it by random angle
Then you get float number in range from min to max, and multiply that vector by it.
So now you have randomly rotated vector that is MIN…MAX from center of circle
Last thing to do is adding player location to that vector (this moves your random point from around [0,0,0] to where player is.
Calculating trajectory for AI to hit that point is whole new can of worms.