Get the Right Vector of a Vector?
Hi there :)!
I'm trying to implement a system in my 3D third-person project that lets my character shimmy along ledges but I've gotten stuck trying to get him to shimmy around outer (convex) corners, more specifically, when trying to get a right or left vector off of my character's forward vector to use as a trace. I've made a quick top-down sketch to show you what I'm trying to do:
So basically, the character is hanging from the wall, facing it, and when the player moves (in this example) to the left, I want the character to move around the corner. To do this I (among other things) need to figure out where exactly the wall continues around the corner, at what angle it continues, etc. (or if there even is a wall there) so I thought I'd first use the character's forward vector to find the starting point of my line trace one capsule-width in front of the current actor location, then trace to the left (or the right, depending on the direction you're shimmying in) at a relative 90° angle. The problem, however, is that, no matter which direction the character faces, the trace always goes into the same global direction, meaning it's not relative at all. I've had a similar problem before when trying to use GetActorForwardVector and GetActorRightVector and it was solved on here in this thread: https://answers.unrealengine.com/questions/284926/forward-vector-points-in-wrong-direction.html
However, that fix doesn't seem to be working here. Here's my current set-up (it's not connected to anything because my actual blueprint is a bit messy so I copied this part out of it for the purposes of this screenshot to make it clearer which nodes are relevant to the question): For bigger screens, click on the attachments below. The second screen shows the GetActorForwardVectorCorrectM macro that's used in the bigger screen. If you're wondering why I have to use a custom macro for that instead of the built-in GetActorForwardVector function, it's explained in the thread I linked to above.
I've tried several different things that aren't shown here, including using both MakeRotFromY and MakeRotFromZ instead of MakeRotFromX (I have to confess that I am not entirely sure how those nodes work exactly) and using a RotateVector node with a value of 0,0,90 instead of the MakeRotFromX and GetRightVector nodes but all of those still just gave me traces going into the same global direction, no matter which direction the character was facing when they were triggered.
Here are links for both of those scripts:
So yeah, if you have any idea how I can get that trace to always be at a relative 90° angle to the forward vector or if you think there's a better way entirely to figure out the location and rotation of the wall around the corner (there probably is), I'd be extremely grateful to hear your thoughts :)!
asked Jul 06 '16 at 07:23 PM in Blueprint Scripting
Okay, after getting some distance from the problem and coming back to it with fresh eyes I solved it by attaching a new capsule in front of the character and getting the right vector off of that, rather than trying to use the forward vector as the starting point for the right vector, and now it works.
answered Aug 08 '16 at 01:00 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here