I have spent the last 3 days trying to figure out this problem. I will admit that I am new to Unreal but have not found any tutorials on this particular topic.
My goal: I want to launch my character toward my cursor location. If the location is within range, they will land at the impact location. If they are out of the range, they will be launch toward the impact location. As of right now, I am simply trying to figure out how to launch my character in the direction my mouse is oriented from my character.
What I have been able to achieve: I have been able to launch my character a set distance in the direction the character is facing successfully.
That error is saying: Hit must have an input wired into it (by ref params expect a valid input to operate on).
I think what that means is that my CastLocation function is not a valid place to trace from. The goal of my CastLocation function was to return the value of my current cursor location from my TopDownController.
Then I would be able to draw a line from the location of my character to the location of my cursor, get the direction I want to launch toward with GetWorldRotation and then launch in that direction.
Ok, at first I could see you are trying to collect the hit info but your call of LineTraceByChannel seems never been called.
I have a few things to say about it. First, your Cast Location function will only return a value, without any execution node needed, so you may mark it as pure Second, after you set Can Dash, link the execution node(the white line) to the LineTraceByChannel, and the exec of it, you will link to Launch Character.
Could you explain what you mean by âpure Secondâ?
So now when I execute the skill, my character is being launched north and not in the direction of the cursor. Is my get world rotation and forward vector not returning the direction of my mouse to my character?
It seems the forum editor didnât got my line break. Iâll use double line nowâŚ
itâs just mark it as pure.
Take a look on the picture you have sent. You see how the GetWorldLocation doesnât recieve an execute line but the LineTraceByChannel does?
The pure functions are just this, you donât need to pass the execute line on it, itâll just give the value you want.
Now, back to your problem. The Cast Location is not a pure function, so if you donât pass the execution line to it, it wonât get any value at all. so, open that function, click on the node with the funcion name (the first one where you pull out the white line) and check the box âpureâ that should be on the properties at left, right above the place where you define what vars it get in and out.
If it solves your problem, please, come back here and mark it as resolved, so that could help the others with the same problem as you.
I created the CastLocation function in the TopDownCharacter blueprint and the error disappears. I named the new function MouseTarget. No errors when I compiled but I had the same result as before. I would get launched north from my character location. Also I had a runtime error that popped up after I closed.
The LineTraceByChannel function has two outputs, one with the hit result, and another to check if it hit something or not. Just link that Return Value to a branch. if true, link it the Launch Character, if false, link it to something else
The print string is returning FALSE when I try to launch to an area with no NavMesh on it. However when I click on an area with Navmesh, I am still being launched north and not in the direction of the cursor. It seems like the issue is that I am not getting the actual direction of my cursor from my characters position.
on that Hit Component, there is another data, Iâm thinking that you may use just the ânormalâ on that multiply node instead of the forward vector. If that doesnât work, try to find the lookat rotation between your characterâs location and the âlocationâ on Out Hit
Using Normal Results:
When using the normal to launch, im seeing some weird functionality. If I click on the floor, he gets launched straight into the air. If I click on one of the pillars in the default level in the topdown blueprint, I get launched in the opposite direction of where my cursor is.
Using Lookat Rotation Results:
YES! So I took my get world location and mouse target location function and plugged it into the Find Look at Rotation then plugged those into Get Forward Vector like you suggested. This launches my character in the correct direction now. However I am noticing when I select a point of elevation, my character will bounce off of it depending on the trajectory. Im sure I can set something up to stop my character when coliding with something but the basic functionality is exactly what I was looking for! Here is my blueprint: