Good afternoon. Someone can help?
I found one tutorial from four years ago, which shows how to direct the player’s gaze to the place indicated by the cursor. Everything worked out, but there is a nuance. The arrow that shows the direction rotates only in the right hemisphere, when the cursor is to the left of the character, although he aims at the cursor, but the arrow is inverted to the right. How can this problem be solved?
This error is categorical because any object, in my case an arrow, always flies to the right.
Hi there and welcome to the forum.
I can not resolve your issue sorry. I can tell you it is highly unlikely anyone else will either.
The tutorial you followed… not good.
The mesh being inverted is a dead give-away, I thought at first that was how the character was being ‘turned around’ (so to speak) but those come immediately after set actor rotations and the whole thing is really baffling.
Then there is that Aim Location
function, which does some strange things with three vectors to get an answer. Could be pure genius for all I know, but it looks like trash, and probably is.
I’m guessing you don’t know how it works? A good tutorial should teach you that, or it is not really a tutorial at all.
Maybe look for a better tutorial, even if the one this code is from is math genius, it is still trash for how convoluted it is.
I don’t know how likely it is you will find another tutorial for this exact thing (being a side-scroller), so I can offer some advice on how to maybe adapt the current system so it is something you can understand and work with:
- Throw away
Aim Location
, put a plane through the middle of your level(s), at the X/Y the player will be locked onto, and hit test against that (hit location is then your aim location, no funny math required). - Figure out why the hell the mesh is being inverted when the character is looking left… and… err, idk, depends why it is there… but look to get rid of it.
I know what you mean. Before that, I used this guide.
In general, it worked correctly and was even more suitable for my project, since I plan to introduce episodes when the player will be able to shoot deep, and not just in one plane. However, then I couldn’t figure out how to pass “Pitch” and “Yaw” in order for “Aim Offset” to work. However, when I tried to adjust the depth so that the player could shoot not only to the sides, the sight goes to a certain invisible edge - it went to zero coordinates and that was the end of it. Could you tell me how from the above guide you can transfer “Pitch” and “Yaw” to an Animated BP?
Yes, that’s much better; and Everynone has solved your problem without even posting
To go from the aim location (step 2 in that post) to pitch and yaw you can use this nifty little node:
I’m afraid that I’m too poorly versed in the subject of blueprints for your hint to make me realize exactly what to do. If it’s not difficult for you, can you write what to do in more detail?
I will be very grateful, I am sitting with my problem for the third day.
Hello again. I figured it out and really, the tutorial I was doing was very strange. I was able to make everything work the way I wanted, but in the end I realized what exactly breaks the sight of the left hemisphere, but I don’t understand why.
The fact is that at the very end there is a mesh transformation that turns him inside out, this allows him to make sure that his torso always looks at the camera. For some reason unknown to me, if you put a positive number instead of “-1”, then the arrow does not go crazy. I have some ideas why this is happening, because I really like this detail and I would like to keep it. And if not, maybe there is another way to turn the character around?
this allows him to make sure that his torso always looks at the camera
Ahh, yes that makes sense. Not surprised it is causing problems though
The character facing thing is interesting and I don’t really know enough about what you are going for to advise. I was assuming the character can move left/right, in which case what exactly do you want to do when the character is moving right, but the mouse cursor is to the left?
I had just whipped up a solution based on Everynone’s post you linked, to reply to your previous post with, but just ignored this problem and applied the yaw and pitch to an arrow to demonstrate, and was planning to only mention the movement vs looking problem.
All depends on how exactly things will work, if the player can always move and always look, you have a thorny problem to solve. If it is like switching modes, then things are fairly straight forward.
Thinking on it again… the mirrored mesh shouldn’t really be an issue (at least for the arrow), if the mesh is independent. Do you by chance have the Arrow as a child of the Mesh? It is going mess with socket transforms though (probably what is causing the arrows to fly out wrong).
The idea of the game is quite simple. Yes, the player can only move to the left and right sides, his movement must be blocked in one coordinate so that it is impossible to move in depth.
In turn, the problem of aiming and “Aim Offset” works only when the player presses the right mouse button and holds it, only then he aims and can look up/down.
Accordingly, if the character is aiming, then his turn should be directed after the cursor.
If we talk about the arrow, it’s a difficult question. I’ll just attach a screenshot of the viewport, in the hope that this will be the answer.
Aiming Direction is the location of the line report for the tracing line. Since the binding to the socket caused the problem that if the player aims at a place in the center of the character, for example, where the “Pelvis” is located, then the character starts spinning like a helicopter.
ArrowSpawnPose - it’s clear from the name what it is, but in this case this arrow looks exactly where the cursor is pointing. It is also clear why this was done.
However, the development plans to make segments when the player will be able to aim not in one line with his coordinates, but on the sides, that is, further from the camera or vice versa towards the camera.
Ok, so that is a yes to the arrow being a child of the mesh. If you drag it (AimingDirection) up and drop it on the capsule, that will parent it to capsule and fix it (the arrow wont be inheriting the funny scale).
Fixing ArrowSpawnPose is going to be somewhat more challenging, as you do need/want it as child of the bow. Or do you… the actual direction will be the same as AimingDirection right? So maybe you can discard it and use a socket on the bow to get the location to spawn, and then use (the now fixed) AimingDirection for its rotation?
You are just a genius, Indeed, I pulled the arrows out of the mesh into the capsule and the arrow for shooting became stable, in any direction. Although the ArrowSpawnPose has moved out and the arrows are not coming out of the bow, I think it will be relatively easy to solve. Easier than a broken direction.
Thank you very much for your help, but what is the reason for this problem with the mesh?
Why is it that if the arrow is a child object of Misha, it starts jumping like that because of the scale change?
Awesome, and yeah hopefully the arrow location is solvable without much pain
Child components get their ‘base’ transform from their parent, so with the arrow component(s) as children of the mesh, they get that scale change (-1, 1, 1) when it is applied, which was ‘inverting’ the arrow.
Considering what that scale is doing on the mesh, flipping the arrow component around like it was seems a little funny, and I can’t say I get that; working through the math manually would likely be enlightening.
Yes, now I understand that I was frivolous with heredity.
I have already corrected the position of the ArrowSpawnPose and it is located almost exactly to the point.
Thanks again for your support.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.