I may be terrible at explaining this, but the idea is to generate two transform points, A and B, that go in a straight line, then loop and generate x number of transform points that each are 250 units apart and X degrees in rotation, so they essentially arc. The end result should be two transform points that are straight and then begin to arc as showcased in the image below:
In the function, the very first thing I do is calculate if the current location and destination location require clockwise or counterclockwise rotation to align. This functions perfectly and it sets the rotator amount to be either negative or positive.
Then I generate the first two transform points, A and B:
Then I use a loop to generate a series of transform points, let us call these Ns, ensuring that at the end of the loop, B = N, so the new point generates correctly at the right distance and rotation from previous:
I think I am incorrectly using rotation, because despite the points generating correctly in an arc, debugging the forward vectors (orange lines) of these points, reveals that they are not pointing in the direction that the new point is. In the case of B, its forward vector (orange line) is pointing in a slightly off left, where in the case of Ns, their forward is perpendicular to the next point.
Been spending all day going back and forth, any ideas or suggestions on how to fix this would be appreciated.
Hi thanks, I can certainly try and answers will be in order of your questions.
I am trying to create a series of transform points that will later be turned into spline points. The first two points, A and B, being straight, so that the travel of the actor starts in a straight path and subsequent points either going clockwise or counterclockwise in an arc, meaning a set distance and rotation until the last point is facing the destination (red square top left). At the moment I have disable the while-loop that checks whether we are facing the destination or not at each new point, and instead using a for-loop to troubleshoot the current issues.
The first two points, A and B, are the first two transforms being set. The remaining points are being set by the for-loop. The orange lines are each points forward vector, which clearly are not facing in the direction of the respective next point. So for some odd reason I managed to make the thing curve in an arc, but the forward vectors are not pointing right, which means the whole thing may be setup incorrectly to begin with.
I was not aware that forward vector is already normal, so that is just habit.
As for getting the rotation from A to set for B, I assumed that since I need the next point after B to be in a specific direction, that by setting rotation for B, it would make its forward vector point the right way and I could use that to set the next point.
The RotationAmount is set by an early function that checks for counter/clockwise between actor forward and direction to destination (the tiny red square) and sets RotationAmount to either negative or positive value. In the case of the screenshot, it sets it to counterclockwise and RotationAmount to negative value of 10 or 20.
I have no idea what you’re trying to do really, but here’s a bit of information.
It’s much easier to work in local space within a blueprint ( usually ). But… those debug nodes work in world space.
For instance, if I want to give a start point, and rotate it by a fixed amount around my actor, it’s easy to check with a static mesh component, like this
Yeah, I do apologize for being quite terrible at explaining these things.
…well that sorta explains a bit of the issue.
I essentially need it to generate points in an arc until it is facing the destination.
The method that you shared, would it be possible to get it to keep adding points on its own till it is facing a preset destination?
The destination is acquired from the EQS and it will never be close to the start location which is in front of the AI pawn, it essentially finds a destination based on certain criteria and updates the blackboard, which the AI base class can access to retrieve a destination.
I then use the aforementioned function to generate a series of points that arc towards the destination and it generates the first point to start in front of the AI pawn. I later planned on turning these points to spline points to get a nice curve to travel along.
Your method is cleaner, but obviously I need to adapt it to automate how many points are required to face the destination. That is the only difference as far as I can tell.
Obviously the easiest thing is to just point the arrow at the destination, but I can understand you don’t want to do that.
So, its a matter of plotting N points from start to end, and only adjusting the arrow enough to achieve the correct rotation by the destination? ( that I can work with )
I just didn’t want to convolute things by tossing all sorts of information in there at the beginning.
I have tried several ways over the last couple of weeks to get my AI ships to move in believable manners from A to B. I first attempted with physics propulsion and that worked fine for most, but I had edge cases where sudden destination changes would inflict sudden rotational changes and that looked pretty bad.
So I changed to the idea of using splines and I have most of the functionality down in terms of getting the actor to follow the spline path from A to B. I am at the point where I have to figure out how to make an arc that goes from the ship to the destination.
I can go in a line from A to B and set the points and rotation so the ‘vessel’ is pointing correctly at each point. But what describes the arc? The arc is just to make sure the vessel doesn’t fly sideways, right?
I was planning on using this approach in terms of following a spline:
However, in the above example, the splines are pre-made. I obviously require them to be generated at run-time which is why I set out to make a function that generates them first as points in space and then the idea was to convert the array into spline points.
In such a case I would say that the arc is not only to ensure the vessel doesn’t fly sideways (a problem with the characterMovement component), but also to guide it quite narrowly to face the direction of the spline path. The AI Pawn would essentially never go anywhere until it has a spline path provided with a valid destination. Whether that spline path is arcing or not, depends entirely on the amount of rotation required when generating the points as exemplified by your own method.
EDIT: Could you share how you made your method work, it only shows the construction script. Perhaps I can use that to get to what I need.
I have done something incredibly similar to this for aircraft paths.
So basically the vehicle travels straight between points, so the curve needs to be enough for the object to correct its orientation, and get to the target, without looking weird.
I can have a go at that. Or are you specifically going to be reading points into a datatable?
I don’t want you to do a workload here, feels quite unfair to ask for. I honestly just need a variation of what you already displayed above with the adjustable arc. I can try to make the automation of it myself into what I am thinking of and share my progress.
I think the most efficient way would be to have the arc start in front of the pawn, perhaps the first two points are straight as explained earlier, but then it loops and places a point each time by x distant and degree until one point faces the destination. Then when the last point is facing the destination, we simply exit the loop and make the destination the very last point. I can put all of that into an array as it is being made and then convert the array into position and rotation for spline points in a for-each-loop.
From the example you had above, I can see that you manually type in the number of points and you manually expand the arc, but if these two attributes can be attached to some automation, then that would be the answer.
As far as datasheets go, I think that is too complex for the intended use. This function is suppose to run on the base AI class and is called from the behavior tree to generate a spline path, so I do not need it to be too complex.
Also worth mentioning, I do already use line tracing to detect collision with objects, so the idea later is that if the AI detects something in its line traces, it can then re-evaluate its spline path, either draw a new one, wait a few seconds, but those are behavior tree related.
You choose the number of points, the distance to travel in a straight line before turning, and the start and end rotations. But it’s not enough to choose a destination point.
Ok I am back to it.
Implemented your method and it curves nicely for all intended purposes, but it does have a 180 limitation at which point it will flip to the opposing side. This is not a big deal, as I imagine that the arc is only really needed for a maximum of 180 degrees at which the subsequent the last point can be the destination point and given that these are meant to be converted into a spline curve, the curve points will have tangents to allow for a smooth journey at the end part as well.
I set the distance to 100 flat, I set the number of points to 10 flat and the only attribute that needs to be connected to my MakeASplinePath function is the EndRotation which creates the arc. I am now working on connecting this EndRotation so that the arc faces the destination vector (which the function retrieves from the blackboard).
I also will need to figure out how to extract the position and rotation of each of these arrows, so that I can pass them into a spline.
I added a temporary destination vector that is set manually for the time being (testing purposes). And a few nodes to set end rotation. It is almost correct, you can see the path is pointing at the destination, but it does have a bit of offset that I presume comes from the fact that the nodes I added do not take into account the arc amount. Currently trying to figure this part out.
I was about to write that I have been unsuccessful at making it face the exact direction of the destination, as per my previous post about the offset issue.
I had almost given up, then I noticed that I was setting the End Rotation once instead of setting it inside the loop so it would get properly set for each point.
Well, success, now it is pointing at the exact destination and it can point even behind the ship, albeit at a safe distance to not break the curvature too much.
I have not mastered gif making, so a single shot will do.
Thanks for all the help Clockworkocean, could not have done this without you!
I do hope that in the near future they add some curvature control to the characterMovement component, having fiddle with that for what seems forever, making something curve smoothly and consistently just became a pain. It is very obviously made for humanoids.